Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 374
Vinay Jeurkar Avatar asked Mar 09 '11 01:03

Vinay Jeurkar


People also ask

How do I know if my child window is closed?

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.

How do I close the child window from the parent window?

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!

What is parent window and child window?

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.

What is a child window in windows?

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.


1 Answers

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.

like image 83
JeanK Avatar answered Nov 15 '22 14:11

JeanK