How to capture the close event of an opened window by window.open() in JavaScript?

How to capture the close event of an opened window by window.open() in JavaScript?

asked Oct 16, 2015 by anonymous

1 Answer

This JavaScript code works well for me:

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.

answered Oct 16, 2015 by Eric Z Ma (44,280 points)

Please log in or register to answer this question.

Copyright © SysTutorials. User contributions licensed under cc-wiki with attribution required.
Hosted on Dreamhost

...