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
Iframe source doesn't work
提问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:SAMEORIGIN
http 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:SAMEORIGIN
http 响应标头,它告诉用户代理仅允许在其父级具有相同来源的情况下将页面加载到框架中。