In my web application a lot of popups opened from the parent window using 'window.open'. So I want to close all those popups when my application's main window is closed. How can I do that?
A:
There's no callback
that will notify you that the user closed his browser.
Darin Dimitrov
2009-12-22 08:46:57
A:
It's a bit problematic to know that the user closes the window but assuming you do achieve that (by a close button or subscribing to the beforeUnload event) you can close the opened windows by following the next bullets:
- When opening a window, save its
object which is returned from the
window.open
method (preferably to an array so you have all objects in a central place). - When you find out the main window is
closing, execute the
close
method on the saved window objects.
Another possibility:
- Use timer on the opened windows to
check if
opener
is defined (you can try to usetypeof
on a method in the opener page). - When you find out the opener doesn't exist, close the window.
Shay Friedman
2009-12-22 08:47:48
A:
its not possible! You cannot catch browser close event.
You can use model popups to be sure user closed popups before closing the main window.
Ozan BAYRAM
2009-12-22 09:40:30