我正在写一个小网页,它的目的是框架其他一些页面,只是为了将它们合并到一个浏览器窗口中,以便于查看。一些页面,我试图框架禁止被框架,并抛出“拒绝显示文档,因为显示禁止X-Frame-Options.”错误在Chrome。我知道这是一个安全限制(有充分的理由),并且无法更改它。

是否有任何替代的框架或非框架方法来在单个窗口中显示页面,而不会被X-Frame-Options报头绊倒?


当前回答

编辑.htaccess如果你想从整个目录中删除X-Frame-Options。

并添加一行:Header always unset X-Frame-Options

[内容来自:克服“x帧选项禁止显示”

其他回答

网站所有者使用X-Frame-Options响应报头,这样他们的网站就不能在Iframe中打开。这有助于保护用户免受点击劫持攻击

如果你想在自己的机器上禁用X-Frame-Options,可以尝试几种方法。

服务器端配置

如果您拥有服务器或可以与站点所有者合作,那么您可以要求设置一个配置,以根据某些条件不发送Iframe buster响应标头。条件可以是额外的请求头或URL中的参数。

例如,站点所有者可以添加一个额外的代码,当站点打开时不发送Iframe buster报头,使用?in_debug_mode=true查询参数。

使用浏览器扩展,如Requestly删除响应头

您可以使用任何浏览器扩展,如Requestly,它允许您修改请求和响应头。这里有一个Requestly博客,解释了如何在Iframe中嵌入站点,绕过Iframe buster头。

配置一个直通代理,并从它删除标题

如果你需要为多人绕过Iframe buster报头,那么你也可以配置一个直通代理,它只删除帧buster响应报头并返回响应。然而,这是一个非常复杂的编写和设置。还有一些其他的挑战,比如通过代理在Iframe中打开的站点的身份验证等,但这种方法可以很好地用于简单的站点。

PS -我已经建立了这两个解决方案,并有第一手的经验。

添加一个

  target='_top'

到我的链接在facebook标签为我解决了这个问题…

当我尝试在iframe中嵌入moodle 2时,我也有同样的问题,解决方案是站点管理►安全►HTTP安全并检查允许框架嵌入

更新2019:您可以使用客户端JavaScript和我的X-Frame-Bypass Web组件绕过<iframe>中的X-Frame-Options。下面是一个演示:x帧旁路中的黑客新闻。(在Chrome和Firefox中测试。)

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.