如何在 iframe 中显示 google.com? [英] How to show google.com in an iframe?
问题描述
我正在尝试将 google.com 放入我网站上的 iframe,这适用于包括雅虎在内的许多其他网站.但它不适用于谷歌,因为它只显示一个空白的 iframe.为什么不渲染?有什么技巧可以做到这一点吗?
I am trying to put google.com into an iframe on my website, this works with many other websites including yahoo. But it does not work with google as it just shows a blank iframe. Why does it not render? Are there any tricks to do that?
我已经尝试过以通常的方式在 iframe 中显示网站,如下所示:
I have tried it in an usual way to show a website in an iframe like this:
<iframe name="I1" id="if1" width="100%"
height="254" style="visibility:visible"
src="http://www.google.com"></iframe>
google.com 页面不会在 iframe 中呈现,它只是空白.这是怎么回事?
The google.com page does not render in the iframe, it's just blank. What is going on?
推荐答案
这样做的原因是,Google 正在发送一个X-Frame-Options: SAMEORIGIN"响应头.此选项可防止浏览器显示与父页面不在同一域中的 iFrame.
The reason for this is, that Google is sending an "X-Frame-Options: SAMEORIGIN" response header. This option prevents the browser from displaying iFrames that are not hosted on the same domain as the parent page.
请参阅:Mozilla 开发者网络 - X-Frame-Options 响应头
这篇关于如何在 iframe 中显示 google.com?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!