开发者

Close all popup dialogs when main window closed in ASP.NET

I开发者_运维技巧n 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?


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:

  1. 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).
  2. When you find out the main window is closing, execute the close method on the saved window objects.

Another possibility:

  1. Use timer on the opened windows to check if opener is defined (you can try to use typeof on a method in the opener page).
  2. When you find out the opener doesn't exist, close the window.


There's no callback that will notify you that the user closed his browser.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜