IFrames and mistery! Can someone explain?

IFrames and mistery! Can someone explain?

Post by Tom Szab » Thu, 09 Dec 2004 16:23:36

I have been learning and practicing JS for a few weeks now. I have a good
understanding of most things and came up with a few complex modules.
Basically I am almost comlpleted my library code that is needed for some
development soon.

Unfortunately I am having a real confusion with IFrames. In order to achieve
some of my goals I have arrived to the conclusion that IFrames will suit the

Well, in theory they would. In practice I have no idea...

... why => window.parent.parent == window.parent ???

I have a page with a DIV and an IFRAME in it and I fill the DIV with a table
etc, and load the IFRAME with a URL. From the content of the DIV I use JS to
change the content of the IFRAME and I like to trigger from the content of
the IFrame a reload on the whole page. While trying to achieve the I had to
play around with reference to objects, and this is when I have found the
above ...

So "window.parent" actually the same as "window.parent.parent". I thought I
have to do more test, did not want to beleive it!

So I have created a variable in the main page ->

var oTask_DTV_Var = " Orig Value";

....using from the page contained in the IFrame ...

window.alert(window.parent.oTask_DTV_Var) -> " Orig Value";

window.alert(window.parent.parent.oTask_DTV_Var) ; -> " Orig Value";

So both of the above expressions produce the same result.

??????? What am I missing????



IFrames and mistery! Can someone explain?

Post by VK » Thu, 09 Dec 2004 20:16:43

> ??????? What am I missing????

That you cannot go beyond the Creation point :-)
You cannot trace the human parentship deeper than Adam ;-), and you cannot
go further than the original parent window. After that 'parent' becomes a
self-reference ('self' property).
You may try though window.parent............parent.....parent and so on, to
see if the Lord pops up anywhere in the chain :-)