Determining that a child window has closed

T

Tim Streater

I'm getting some crashes with Safari and my web app. Now, it occurs to
me that I'm doing this:

winPtr = window.open (parameter, ...);

I'm saving a reference to the child window, so that on exiting the app I
can do:

if (winPtr!=null) winPtr.close ();

so that, on exit, there are not stray child windows left hanging around
(note: I tried the "dependent" parameter for window.open but this did
not appear to work in Safari).

Of course, if the child window was already closed, then I don't know if
Safari cares that winPtr now refers to a no-longer-existing element (it
shouldn't, IMO. Or at any rate it shouldn't crash).

In the child window I can do:

window.opener.winPtr = null;

just before the window.close(), but I'm not sure whether it's possible
to be informed if the user clicks the red "close" button on the child
window, rather than clicking my "Cancel" button.

Is there a way for an opener window to be informed unambiguously that a
child window has closed or been closed?

Thx,
 
T

Tim Down

Is there a way for an opener window to be informed unambiguously that a
child window has closed or been closed?

Check winPtr.closed is false before calling winPtr.close().

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top