最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window.top === window false condition in IE8 - Stack Overflow

programmeradmin1浏览0评论

For some reason, using the

window.top === window

condition in IE8 always evaluates to false (in other browsers it works fine). What is the reason for this, and is there any other way for this condition to work cross-browser?

Thanks,

Joel

For some reason, using the

window.top === window

condition in IE8 always evaluates to false (in other browsers it works fine). What is the reason for this, and is there any other way for this condition to work cross-browser?

Thanks,

Joel

Share Improve this question asked Feb 13, 2011 at 12:35 JoelJoel 6,10712 gold badges44 silver badges59 bronze badges 2
  • ...and definitely not within a frame? :P – alex Commented Feb 13, 2011 at 12:37
  • @alex - yup... i am using this code inside a page that is sometimes served inside an iframe. I need to check if it is the top window or an iframe – Joel Commented Feb 13, 2011 at 12:43
Add a ment  | 

1 Answer 1

Reset to default 13

It's a very plicated topic, but the short version is, use == when paring windows, not ===, because of the "internal" vs. "external" reference aspect of it. You'll find that (for instance) window === self is false on some browsers.

发布评论

评论列表(0)

  1. 暂无评论