I want to execute a function when an opened child window is closed. Child window opening code is:
outWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=400, top=100, left=100);
I want to call a Javascript function written in parent window. I am using YUI-2 for developing the plugin. How can I make it work? What event should be registered?
If you store a reference to the child window when you call window. open() , then you can poll using setInterval() to see whether the window is still open using the window. closed property.
A child window opens as separate window as a tab. Go back to the parent and click “Close child” and the child window closes. Viola!
For example, if the application starts off by creating two floating windows in a row, the parent of the first window will be the main application window, while the parent of the second window will be the first window. The converse of a parent window is a child window.
A child window is the direct descendant of a specified parent window if that parent window is in the chain of parent windows; the chain of parent windows leads from the original overlapped or pop-up window to the child window.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With