Join the Discussion
You can also close the window from the same window that opened it. When you call the window.open() method it returns a value that "points" to the new window. By assigning this returned value to a variable we obtain a way to reference that window in order to close it.
var newwin = window.open();
Another thing that we can do from the page that called the window.open() is to be able to test if the window that was opened has already been closed.
if (newwin && !newwin.closed)
Of course you don't have to use "newwin" as your variable name for referencing the other window, you can assign whatever name you like when you first open the window and so of course you can use multiple values to reference multiple windows that are opened from the same page. Don't go opening too many windows though or you might annoy your visitors. Perhaps you should test that one window has been closed before opening another.