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

后端 未结 8 871
没有蜡笔的小新
没有蜡笔的小新 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 19:01

    I created a watcher that checks if the window has been closed:

    var w = window.open("http://www.google.com", "_blank", 'top=442,width=480,height=460,resizable=yes', true);
    var watchClose = setInterval(function() {
        if (w.closed) {
         clearTimeout(watchClose);
         //Do something here...
        }
     }, 200);
    

提交回复
热议问题