我正在写一个小网页,它的目的是框架其他一些页面,只是为了将它们合并到一个浏览器窗口中,以便于查看。一些页面,我试图框架禁止被框架,并抛出“拒绝显示文档,因为显示禁止X-Frame-Options.”错误在Chrome。我知道这是一个安全限制(有充分的理由),并且无法更改它。
是否有任何替代的框架或非框架方法来在单个窗口中显示页面,而不会被X-Frame-Options报头绊倒?
我正在写一个小网页,它的目的是框架其他一些页面,只是为了将它们合并到一个浏览器窗口中,以便于查看。一些页面,我试图框架禁止被框架,并抛出“拒绝显示文档,因为显示禁止X-Frame-Options.”错误在Chrome。我知道这是一个安全限制(有充分的理由),并且无法更改它。
是否有任何替代的框架或非框架方法来在单个窗口中显示页面,而不会被X-Frame-Options报头绊倒?
当前回答
这就是解决办法!!
FB.Event.subscribe('edge.create', function(response) {
window.top.location.href = 'url';
});
这是唯一适用于facebook应用的方法!
其他回答
当我尝试在iframe中嵌入moodle 2时,我也有同样的问题,解决方案是站点管理►安全►HTTP安全并检查允许框架嵌入
编辑.htaccess如果你想从整个目录中删除X-Frame-Options。
并添加一行:Header always unset X-Frame-Options
[内容来自:克服“x帧选项禁止显示”
我几乎尝试了所有的建议。然而,唯一真正解决这个问题的是:
在PHP文件所在的文件夹中创建一个.htaccess文件。 将这一行添加到htaccess: 报头总是不设置x帧选项
通过来自另一个域的iframe嵌入PHP之后应该可以工作。
此外,你可以在你的PHP文件的开头添加:
header('X-Frame-Options: ALLOW');
然而,在我的情况下,这是不必要的。
试试这个东西,我认为没有人在主题中建议过这个,这将解决你70%的问题,对于其他一些页面,你必须废弃,我有完整的解决方案,但不是公开的。
添加到下面的iframe中
沙箱="允许-同源允许-脚本允许-弹出窗口允许-表单"
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.