0

我尝试用 iframe 加载一个具体的网页:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <iframe id="frame" src="http://www.euronics.ee/" frameBorder="0" width="1000px" height="700px"></iframe>
    </body>
</html>

为什么它无法加载整个页面。它只加载身体?如果我尝试,它会很好地加载另一个页面。

4

2 回答 2

5

如果您检查该站点代码,您将看到:

<script type="text/javascript">
            //This block of javascript checks if the current page is opened in a popup IFrame
            //and if this is true - closes popup and reloads parent window.
            //We use Popup template for popup windows and only this template is accepted for popups. A window with any other template will be closed immidiately.
            //This also solves the problem with redirecting to parent after user has logged in via Login popup. After loggin in user is redirected back to My Account page
            //which in turn uses Audio template thus immidiately gets closed and parent gets reloaded.
            if (self != top) {
                $("body").empty(); //also clears body to avoid showing page content while the page is closing
                parent.location.reload();
            }
 </script>

这就是为什么我猜它不会在你的 iframe 中加载网站的原因。不是每个人都喜欢将他们的网站显示在 iframe 中的其他网站上的想法。我会说他们只想要真正的访客。

于 2013-07-16T17:25:02.830 回答
0

当我在 jsfiddle 中尝试它时,我收到以下控制台错误:阻止具有来源“ http://www.euronics.ee ”的框架访问具有来源“ http://fiddle.jshell.net ”的框架。协议、域和端口必须匹配。会不会是您正在加载的网站有 https 请求?

于 2013-07-16T17:30:46.983 回答