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

Close Named Window

Status
Not open for further replies.

kaeserea

Programmer
Feb 26, 2003
164
DE
Hello!

How do I close a window which was opened from a different page than the one that should close the window?

The window to be closed has a name but statements like

window.MyName.close()
window["MyName"].close()

don't work.

Thanx
Eva
 
This may look weird, but you first create a reference to the named window using window.open (don't worry, it doesn't open a window if the name already exists). Then you close it:
Code:
open('','MyName').close();

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
I think you can also give the window object a name when created, and close it from that.

myWin = window.open(...);
myWin.close();

--Glen :)

Memoria mihi benigna erit qui eam perscribam
 
Glen,

Yes, but only from the page that opened it. The variable "myWin" won't exist on other pages unless you create it and link it to the existing popup by using the "target" argument of window.open().

Code:
myWin = window.open('','MyName');
myWin.close();
This code basically does the same as my first post.

Adam

There are only 10 types of people in the world: Those who understand binary, and those who don't
 
Hi Adam,

fantastic! It works. I had the same that Glen's solution didn't work as the object of the opened window wasn't there for the third window.

Adam held Eva ;-) nice.

Nice weekend!
Eva
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top