我正在写一个小网页,它的目的是框架其他一些页面,只是为了将它们合并到一个浏览器窗口中,以便于查看。一些页面,我试图框架禁止被框架,并抛出“拒绝显示文档,因为显示禁止X-Frame-Options.”错误在Chrome。我知道这是一个安全限制(有充分的理由),并且无法更改它。
是否有任何替代的框架或非框架方法来在单个窗口中显示页面,而不会被X-Frame-Options报头绊倒?
我正在写一个小网页,它的目的是框架其他一些页面,只是为了将它们合并到一个浏览器窗口中,以便于查看。一些页面,我试图框架禁止被框架,并抛出“拒绝显示文档,因为显示禁止X-Frame-Options.”错误在Chrome。我知道这是一个安全限制(有充分的理由),并且无法更改它。
是否有任何替代的框架或非框架方法来在单个窗口中显示页面,而不会被X-Frame-Options报头绊倒?
当前回答
如果你试图在iframe中嵌入谷歌Map时遇到这个错误,你需要在源链接中添加&output=embed。
其他回答
我有一个类似的问题,我试图在一个iframe中显示我们自己网站的内容(作为一个带有Colorbox的lightbox样式的对话框),并且我们在源服务器上有一个服务器范围的“X-Frame-Options SAMEORIGIN”报头,防止它加载到我们的测试服务器上。
这似乎没有被记录在任何地方,但如果你可以编辑你试图iframe的页面(例如。,它们是你自己的页面),简单地发送另一个X-Frame-Options报头,任何字符串都禁用SAMEORIGIN或DENY命令。
如。对于PHP,放入
<?php
header('X-Frame-Options: GOFORIT');
?>
在页面的顶部会使浏览器将两者结合起来,从而导致页眉为
X-Frame-Options SAMEORIGIN, GOFORIT
...并允许您在iframe中加载页面。当初始的SAMEORIGIN命令设置在服务器级别时,这似乎可以工作,并且您希望在逐页情况下重写它。
祝你一切顺利!
编辑.htaccess如果你想从整个目录中删除X-Frame-Options。
并添加一行:Header always unset X-Frame-Options
[内容来自:克服“x帧选项禁止显示”
I came across this issue when running a wordpress web site. I tried all sorts of things to fix it and wasn't sure how, ultimately the issue was because I was using DNS forwarding with masking, and the links to external sites were not being addressed properly. i.e. my site was hosted at http://123.456.789/index.html but was masked to run at http://somewebSite.com/index.html. When i entered http://123.456.789/index.html in the browser clicking on those same links resulted in no X-frame-origins issues in the JS console, but running http://somewebSite.com/index.html did. In order to properly mask you must add your host's DNS name servers to your domain service, i.e. godaddy.com should have name servers of example, ns1.digitalocean.com, ns2.digitalocean.com, ns3.digitalocean.com, if you were using digitalocean.com as your hosting service.
试试这个东西,我认为没有人在主题中建议过这个,这将解决你70%的问题,对于其他一些页面,你必须废弃,我有完整的解决方案,但不是公开的。
添加到下面的iframe中
沙箱="允许-同源允许-脚本允许-弹出窗口允许-表单"
我在mediawiki上遇到了同样的问题,这是因为服务器出于安全原因拒绝将页面嵌入到iframe中。
我写了
$wgEditPageFrameOptions = "SAMEORIGIN";
导入mediawiki PHP配置文件。
希望能有所帮助。