View Full Version : close a window knowing only its name

12-07-2004, 08:37 PM
How does one close a window in javascript if all you know is the name of the window?

12-07-2004, 10:00 PM
If you know the name of the window (as set in a window.open() command or with window.name='something'), but do not have a pointer to the window itself, you can recreate the pointer by re-opening the window, then close it with the new pointer. The downside to this approach is that if the window is not open in the first place, a new window will be opened and immediately closed.

var w = window.open('',windowName);