Html iframe 源不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12327864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:44:11  来源:igfitidea点击:

Iframe source doesn't work

htmliframe

提问by Jo?o Pedro Junqueira Candido

Why can't this link be the source of an iframe? http://exame.abril.com.br/tecnologia/facebook/noticias/facebook-nao-tem-planos-de-voltar-a-china-diz-executivo

为什么这个链接不能成为 iframe 的来源? http://exame.abril.com.br/tecnologia/facebook/noticias/facebook-nao-tem-planos-de-voltar-a-china-diz-executivo

im using jquery $("#frame").attr("src",source);

我使用 jquery $("#frame").attr("src",source);

回答by Josh

Running this:

运行这个:

<html>
    <head></head>
    <body>
        <iframe width="500" height="500" src="http://exame.abril.com.br/tecnologia/facebook/noticias/facebook-nao-tem-planos-de-voltar-a-china-diz-executivo">
        </iframe>
    </body>
</html>

In Chrome yields:

在 Chrome 产量中:

Refused to display document because display forbidden by X-Frame-Options.

拒绝显示文档,因为 X-Frame-Options 禁止显示。

Which is explained here.

这是解释here

回答by Musa

It has the X-Frame-Options:SAMEORIGINhttp response header, which tells the user agent to only allow the page to be loaded in a frame if its parent has the same origin.

它具有X-Frame-Options:SAMEORIGINhttp 响应标头,它告诉用户代理仅允许在其父级具有相同来源的情况下将页面加载到框架中。