Html 无法在 iframe 标签中显示某些网站
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6663244/
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
Can't show some websites in iframe tag
提问by Nikhil Sharma
I am trying to develop a page in which I can show more than 3 website at a time, as below:
我正在尝试开发一个页面,我可以在其中一次显示 3 个以上的网站,如下所示:
<ul>
<li>
<iframe src="http://www.facebook.com/" /><p> iframe is not supported</p>
</li>
<li>
<iframe src="http://www.yahoo.com/"></iframe>
</li>
<li>
<iframe src="http://www.google.co.in"></iframe>
</li>
</ul>
The problem is that it shows yahoo.com and google.co.in, but does not display Facebook in the iframe.
问题是它显示了 yahoo.com 和 google.co.in,但没有在 iframe 中显示 Facebook。
回答by Fire-Hox
You have to check for HTTP response header X-Frame-Option of those sites. if its value is "DENY or SAMEORIGIN", then you can not load those website in the iframes.
您必须检查这些站点的 HTTP 响应标头 X-Frame-Option。如果它的值为“DENY 或 SAMEORIGIN”,则您无法在 iframe 中加载这些网站。
DENY = No one can load the website in iframe. Even the same domain page wont be able to load. SAMEORIGIN = only a page which is in same domain can load this website in iframe.
DENY = 没有人可以在 iframe 中加载网站。即使是同一个域页面也无法加载。SAMEORIGIN = 只有同一域中的页面才能在 iframe 中加载此网站。
回答by zatatatata
Since some websites have decided to disable embedding them in iframes theres nothing you can do with pure html solutions. You could create a serverside script (in PHP) that pulls the target site via your webserver and then use the html etc.
由于某些网站已决定禁止将它们嵌入 iframe,因此纯 html 解决方案无能为力。您可以创建一个服务器端脚本(在 PHP 中),通过您的网络服务器拉出目标站点,然后使用 html 等。
The only way I can think of that would enable you to check wether the site has loaded is to search the iframe for a specific element that exists on the target website (for example a div with a specific id or class on the Facebook's front page). The reason would be that different websites can handle being embedded into iframes differently and while some might display some content, some may display nothing etc and the only way to be sure is to check for real elements.
我能想到的唯一方法是让您检查网站是否已加载是在 iframe 中搜索目标网站上存在的特定元素(例如,在 Facebook 的首页上具有特定 id 或类的 div) . 原因是不同的网站可以以不同的方式处理嵌入到 iframe 中,而有些网站可能会显示某些内容,有些则可能什么都不显示等,唯一可以确定的方法是检查真实元素。
回答by Sudantha
facebook does not want you to load their main site in frames
facebook 不希望您在框架中加载他们的主站点
<iframe src="http://m.facebook.com/" width="200" height="300" scrolling="auto" frameborder=0></iframe>
width="200" height="300"
can be adjusted accordingly.*
width="200" height="300"
可以相应调整。 *
What this does is load the mobile version of facebook in the frame instead of the main site.
这样做是在框架中加载移动版 facebook 而不是主站点。
回答by Cin Sb Sangpi
You will not able to do that, you can only iframe like button... someother not whole site.
您将无法做到这一点,您只能使用 iframe 之类的按钮……而不是整个网站。