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:

  
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 powered by Disqus