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
1 Answer
Reset to default 13It'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.