How to capture the close event of an opened window by window.open() in JavaScript?
如何通过JavaScript中的 window.open()捕获打开的窗口的关闭事件?
This JavaScript code works well for me:
此JavaScript代码对我来说效果很好:
var newwindow = window.open("/newwindow.html");
newwindow.onbeforeunload = function () {
// processing event here
alert("new window closed");
}
Note that after the callback function is executed, the newwindow is closed.
请注意,执行回调函数后,将关闭newwindow。
Answered by Eric Z Ma.
埃里克·马(Eric Z Ma)回答。