由于其"X-Frame-Options"拒绝在框架中显示网站

Ash*_*hir 4 html javascript iframe x-frame-options

我试图在一个只包含iframe的简单HTML页面中显示Facebook页面.

这是我的HTML代码:

<html>
    <body>
        <iframe src="http://www.facebook.com"></iframe>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

我总是在谷歌Chrome控制台中收到此错误:

拒绝在一个框架中显示" http://www.facebook.com/ ",因为它将"X-Frame-Options"设置为"DENY".

顺便说一下,我对这些iframe也有这个问题:

<iframe src="https://mail.google.com/mail/mu/mp/any"></iframe>
<iframe src="http://m.facebook.com"></iframe>
<iframe src="http://m.youtube.com"></iframe>
<iframe src="http://m.dropbox.com"></iframe>
<iframe src="http://m.yahoo.com"></iframe>
<iframe src="http://www.google.com"></iframe>
<iframe src="http://mail.google.com"></iframe>
<iframe src="http://www.facebook.com"></iframe>
<iframe src="http://www.youtube.com"></iframe>
<iframe src="http://www.dropbox.com"></iframe>
<iframe src="http://www.yahoo.com"></iframe>
Run Code Online (Sandbox Code Playgroud)

同时,这个iframe运作良好!

<iframe src="http://www.google.com/custom"></iframe>
Run Code Online (Sandbox Code Playgroud)

怎么解决这个?

编辑基于评论:
如果这是无法解决的,是否有使用iframe的替代方法?像browser标签一样的东西XUL?我已经在Firefox扩展程序中尝试过浏览器标记,但它运行良好,但我现在正在编写一个chrome扩展,所以我不能再依赖于XUL了?

Chl*_*loe 7

是的,你可以

  • 使用服务器端包含,从服务器获取它并将其包含在iframe中
  • 使用无法识别该标头的自定义浏览器
  • 复杂:使用websockets创建自己的Javascript HTTP客户端,获取页面并将其插入DOM


Ash*_*hir 5

对于那些有兴趣的人,这是不可能的!