浏览器不允许 iframe 进行重定向?

Phư*_*yễn 4 iframe google-chrome

Google Chrome 23 和 Firefox 18 让我抓狂。我有一个页面,其中有一个 iframe。单击按钮时,我希望打开 iframehttp://images.google.com

问题是 iframe 将尝试访问http://images.google.com,但是一旦它收到重定向指令(http://images.google.com正在发出),它就会停止并且页面将不会' t 被渲染。这是为什么?有什么解决办法吗?

这是演示该问题的片段:

<iframe id="panel" style="height: 800px; width: 100%" sandbox="allow-scripts" src="http://images.google.com">
</iframe> 
Run Code Online (Sandbox Code Playgroud)

Kam*_*eri 5

这是一个浏览器安全问题,称为点击劫持预防,其中一部分是检查 HTTP 响应标头X-Frame-Options。此标头可以采用值DENYSAMEORIGINALLOW-FROMorigin ,这将分别防止任何成帧、防止外部站点成帧或仅允许指定站点成帧。

简而言之,当此 http 标头存在时,它会阻止网站以 a<frame><iframe>. 自 2009 年以来,大多数浏览器都实现了此 http 标头,包括 IE8+、Safari、Firefox、Chrome 和 Opera。

以下是来自 的标头images.google.comSAMEORIGIN意味着该地址只能在浏览时在 iframe 内呈现google.com

在此输入图像描述