Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling windows using their names

Status
Not open for further replies.

WhizeGie

Technical User
Jan 13, 2001
2
US
I have a web page that opens multiple pop up windows using window.open(). I need the pop up windows to be able to close one another using their names.

Example:

testwin = window.open('','win_1');
testwin.document.write('<a href=&quot;#&quot; onclick=&quot;win_2.close();win_3.close();&quot;>Click Me</a>');

testwin2 = window.open('','win_2');
testwin.document.write('<a href=&quot;#&quot; onclick=&quot;win_1.close();win_3.close();&quot;>Click Me</a>');

testwin3 = window.open('','win_3');
testwin.document.write('<a href=&quot;#&quot; onclick=&quot;win_1.close();win_2.close();&quot;>Click Me</a>');

The onclicks always come up with &quot;win_test3 is undefined&quot;

Please help! Thanks
 
I think this is because you have actually attached the windows to variables, like:

testwin = window.open('','win_1');

So the variable testwin holds the window, and this variable resides in the window which spawned the popups. You need to be careful what you are trying to reference I think. So try this:

wintest1.document.write('<a href=&quot;#&quot; onclick=&quot;wintest2.close();wintest3.close();&quot;>Click Me</a>');


So we are using the variables instead.If you have trouble finding the window variables from the popups, you can reference the 'parent' window using opener, not parent.
&quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Actually Opener won't work because I left out a little information...which I am pretty sure is leading me to a dead end. I have the main web page, which opens up a small window...the small window opens up the multiple windows and then shuts itself down so that only the smaller alert windows are open. Because the opener is no longer open I can not refer to opener. That's why I need a way to refer to a window using it's not, not associations. I'm starting to figure out that it can't be done, but if it is possible please let me know. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top