How Can a parent window know that its child window closed?

You can try acces the parent window by:

window.opener.functionThatYouWant();

This code is inside de child window.

But if you open an window that the URL is in another domain (not localhost), you can't access it because of security issues.

I used this code on Firefox, I am not sure if it works crossbrowser.


You could do something like this.

var intervalID, childWindow;

childWindow = window.open("http://www.google.com");

function checkWindow() {
    if (childWindow && childWindow.closed) {
        window.clearInterval(intervalID);
        alert('closed');
    }
}
var intervalID = window.setInterval(checkWindow, 500);

References: window.setInterval and this answer.

Simple example on jsfiddle.