Window.parent is always undefined in an iframe
I recently ran into this weird problem, I was trying to reference the parent window in an iframe, but somehow window.parent or parent is always undefined.
I had a problem using window.top, but this question still haunts me.
Why is window.parent undefined?
It's a .NET web app if it helps.
Refresh . I would like to add that both parent and child iframes point to the same domain (localhost). As far as the code goes, I tried the following code:
if (parent != null)
{
// do something
}
where something never happens, I also tried
alert(parent)
and
alert(window.parent)
they always come out as null.
+2
source to share
2 answers