【问题标题】:IE6 _top links inside iframe between domains域之间的 iframe 内的 IE6 _top 链接
【发布时间】:2010-12-16 10:31:11
【问题描述】:

我有一个包含 iframe 的域,其中包含来自另一个域的内容。在这个 iframe 里面是 _top 链接。在 IE6 上,当您单击它们时,什么都不会发生。我已经准备了一个最小的例子。请用IE6去http://www.bemmu.com/static/top.html试试看。

编辑:这似乎只发生在安全级别为“高”(或者可能是自定义)的情况下,这在我全新安装的 IE 中是默认设置的

http://www.bemmu.com/static/top.html的来源:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
    <body>
        <iframe src="http://bemmu4.appspot.com/static/iframe.html"/>
    </body>
</html>

http://bemmu4.appspot.com/static/iframe.html的来源:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
<html>
    <body>
        <a href="http://www.google.com" target="_top">Let's go to Google!</a>
    </body>
</html>

有没有办法让这些 _top 链接正常工作?

【问题讨论】:

    标签: iframe cross-browser internet-explorer-6


    【解决方案1】:

    我的机器上没有安装 ie6,但我认为你可以在 iframe 中尝试一个小技巧,使用window.top.location.href='http://www.google.com'; 在锚标记中设置 onclick 属性。有用吗?

    【讨论】:

    • 虽然您提供了更多解释代码,但答案相同。 :) 但是当秒变成分钟时,没有人会看到我是第一个。
    • 好吧,我都平等地看待了 :) 两者都不起作用。好吧,我想我可以没有解决方案,IE6 上的高安全模式似乎非常严格,甚至不允许 document.write 或 alert()
    • 你能通过 try{CODE}catch(e){document.write(something)} 捕获异常吗?如果是这样,也许您至少可以警告您的用户它在该安全配置中不起作用。
    【解决方案2】:

    使用这样的东西对你有用吗?

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd">
    <html>
        <body>
            <a href="http://www.google.com" target="_top" onclick="javascript:if(window.top){window.top.location='http://www.google.com';}">Let's go to Google!</a>
        </body>
    </html>

    【讨论】:

    • 好主意,但行不通。它确实可以直接从页面工作,但不是在 iframe 内时。
    猜你喜欢
    • 1970-01-01
    • 2010-12-13
    • 2014-05-27
    • 1970-01-01
    • 2021-12-07
    • 2012-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多