无法将google.com作为src添加到IFrame [英] can't add google.com as src to an IFrame

查看:60
本文介绍了无法将google.com作为src添加到IFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何在iframe中显示google.com?

为什么不能将某些网站作为源添加到我的iframe中

Why some websites can't be added as source to my iframe

我有此代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script>
        function changeIframe(newLocation){
            document.getElementById("myIframe").src=newLocation;
        }
        </script>
    </head>
    <body onload="changeIframe('http://www.example.com')">
        <div style="width:650px;float:auto;border:1px dotted #cccccc;">
            <iframe id="myIframe" src="http://www.ebay.co.uk/" width="100%" height=750px marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=1 scrolling=auto>
              <p>Your browser does not support iframes.</p>
            </iframe>
        </div>
    </body>
</html>

如果我将 http://www.example.com 更改为

If i change http://www.example.com to http://www.google.com it doesn't show any content. I have tested it with chrome, IE, FF.

那是为什么?

谢谢

推荐答案

Google将x-frame-options响应标头设置为SAMEORIGIN

Google sets the x-frame-options response header to SAMEORIGIN

https://developer.mozilla.org/zh-CN/docs/The_X-FRAME-OPTIONS_response_header

这篇关于无法将google.com作为src添加到IFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆