本文介绍了iframe与外部页面不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正努力在iframe中嵌入一个网页,但它根本不起作用。具有相对路径的内部页面正常显示。但这个简单的代码不起作用: < iframe src =http://www.google.com/ >< / iframe中>
应该显示iframe的地方只是空的。
这怎么可能?
解决方案
Google使用X-FRAME-OPTIONS HTTP标头禁止将页面放入iframe:
I'm tring to embed a webpage in an iframe, but it doesn't work at all. internal pages with relative path are displayed normally. but this simple code doesn't work:
<iframe src="http://www.google.com/"></iframe>
the place that supposed to show the iframe is just empty. i looked in the page source and there is nothing after
How can this be?
解决方案
Google uses an X-FRAME-OPTIONS HTTP header to disallow putting their pages in iframes:https://developer.mozilla.org/en/The_X-FRAME-OPTIONS_response_header
Almost all modern browsers will refuse to put pages with this HTTP header in an iframe. There's nothing you can do about that.
这篇关于iframe与外部页面不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!