【问题标题】:javascript / IE 6/7: check if within an iframejavascript / IE 6/7:检查是否在 iframe 内
【发布时间】:2010-02-26 13:21:28
【问题描述】:

我有一个页面需要检查它是否包含在 iframe 中,无论该页面是否是首页。

我试过这样做:if(window == window.parent),它适用于 Opera、FF 和 Chrome,但不适用于 IE。我应该在 IE 中使用一些技巧吗?

【问题讨论】:

    标签: javascript internet-explorer iframe


    【解决方案1】:
    if (top != self)
    {
        // I'm in an iframe
    }
    

    【讨论】:

    • … 或其他类型的框架。
    • +1 我在一个 iframe facebook 应用程序中使用它,该应用程序也可以从外部访问(两者都使用 FB Connect)。由于 try { window.parent.location } .. 在每个浏览器中导致非常不同的错误(Chrome 显示死机错误),我不知道为什么应该允许这种方法工作。
    猜你喜欢
    • 2010-10-15
    • 2011-03-06
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多