How would I raise an event (jQuery or vanilla Javascript) when a popup window is closed?

后端 未结 8 857
没有蜡笔的小新
没有蜡笔的小新 2021-02-13 18:06

I want to raise an event when a popup window is closed, or preferably, just before closing. I\'m storing the popup window object as an object, but I don\'t know of any way to bi

8条回答
  •  走了就别回头了
    2021-02-13 18:45

    There's one tiny catch I have to mention in relation to the previous mentions of onunload based on my previous experience:

    Opera 9.0.x-9.2.x only runs window.onUnload if the user navigates away from a page. If the user instead closes the window, the event will never fire. I suspect this was done to combat the self-reloading popup problem (where a popup could reopen itself on page close).

    This has most likely persisted to Opera 9.5.x. Other browsers may also implement this, but I don't believe IE or Firefox do.

提交回复
热议问题