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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing one window from another window

Status
Not open for further replies.

sarak

Programmer
May 3, 2001
25
US
I have a window 'Window1' and window 'Window2'. Window1 is NOT the parent window of Window2 (both are child windows of a third window, 'Main').

I would like to close Window 1 with a link on Window 2.
Does anyone know the correct way to do this? Thanks!
 
Off the top of my head, you should be able to do a window.open() using the name 'Window1' from within javascript in Window2, which will return the window object of Window1. You should then be able to do a close() on the onject. Along the lines of:

myWin = window.open('Window1','about:blank');
myWin.close();

Barbie. Leader of Birmingham Perl Mongers
 
Thanks for the response, Barbie. However, I must be overlooking something. When I use your code, I open and close a new window. I would like an existing window to close. Could I be missing a step? Thanks!
 
If the window 'Window1' already exists, another window does not open, instead the object myWin takes on the identity of the existing window. So if you then close the object myWin, it's the existing window which is closed.

Barbie. Leader of Birmingham Perl Mongers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top