IE Bug (window === top) === false

前端 未结 4 628
温柔的废话
温柔的废话 2020-12-01 12:59

In IE.

window === top; // false
window === window.window // false
window == top; // true
window == window.window // true

In FF3.6 & Chr

4条回答
  •  Happy的楠姐
    2020-12-01 13:43

    wtfjs is one of my favourite sites for the really wacky oddities you can find in Javascript.

    Unsurprisingly, this little IE feature has got a mention, along with an attempt at an explanation: http://wtfjs.com/2010/02/25/ie-scope

    Whether that explanation is accurate or not, I can't say, but the effect has been noted before.

    So yes, there may be a quirk in IE's DOM here.

    But it wouldn't be the only quirk in IE, and it strikes me as being one of the less important ones. In fact, to be honest, why do this even matter? Other than having a laugh at IE's expense, what is the use-case for ever wanting to compare window === top in a real-world script?

提交回复
热议问题