I have a function in JavaScript which is included in the main HTML document and all embedded iframes
. The function should operate in the main document. So I tried:
function f() {
if (parent === null) {
...do the real work here...
} else {
parent.f(); // Call parent
}
}
That doesn't work. Apparently, parent
is never null
or undefined
. Currently, I use window == parent
which works but I'm uneasy. Is that correct? Why? How compatible is this?