Alessandro Lacava

on Designing and Developing Software. In love with Functional Programming.

Calling a Function of the Opener Window

It is possible, using JavaScript, to call a function pertaining to the opener window, that is the window that, calling window.open, opened the current window. The code to use is the following:

1
2
3
4
if (window.opener) {
  window.close();
  window.opener.foo("bar");
}

First it checks if the opener window is still open. In this case, it closes the current window and call the foo function on the opener window.

Comments