faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

71 of 84 people (85%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I get from a Daughter Window to call a Parent windows Javascript function?

Sep 17th, 2004 13:39
Daniel LaLiberte, Jean-Bernard Valentaten, David Valbuena,


Depends on what is meant by "daughter" and "parent" windows.   There 
are two possibilities.
1. For a frameset containing frames or any window containing iframes, a 
lower level frame can access its parent window via window.parent. So 
Referencing a parent window's function from a child would look like 
this:
  window.parent.myFunction();
2. Every window (except modal dialogs) has a property called opener, 
through which you can access the window that opened it, if any.  This 
opener is not really a "parent", however, in the same sense as the 
nested frames have a parent.  Referencing an opener window's function 
from a child would look like this:
  window.opener.myFunction();
Once you have a window object, you can also access the window's global 
variables, DOM content etc the same way.
HTH,
Jean,
DML