javascript - How can I check whether I'm in the topmost frame? -


I have a function in JavaScript that is included in the main HTML document and all embedded iframes . Function should work in the main document. So I tried:

  function f () {if (parent === null) {... the real work is here ...} else {parent.f (); // call parent}}  

This does not work, obviously, original never null or undefined Does not happen. Currently, I use the window == guardian which works but I am uncomfortable. Is that right? Why? How is it compatible?

Maybe window == top ? Tested with iframes, but I saw that Google uses Gmail on it


Comments

Popular posts from this blog

iphone - How do I make a UIPickerView in a UIActionSheet -

java - Is there an object like a "Set" that can contain only unique string values, but also contain a count on the number of occurrences of the string value? -