Using JavaScript, you can call a function in the opener window: the window that opened the current window by calling
window.open. Here is the code:
if (window.opener) {
window.close();
window.opener.foo("bar");
}
First, it checks whether the opener window is still open. If it is, the code closes the current window and calls the foo
function in the opener window.