GEL wrote:
<snip>
> Does the remote window have to load from the local domain for this to
> work? If so, can I load a local page, that does a redirect
> (location.href) or at a lower server level?
<snip>
You have to be able to access the DOM of the remote window to use that
method, and this is subject to cross-frame security. Refer to:
http://www.jibbering.com/faq/#FAQ4_19
I think you are asking if you can load a dummy page (from the same
domain) into the remote window, set the onbeforeunload event, and then
redirect the remote window to a page from a different domain, and have
the onbeforeunload event still fire when the remote window is closed
while showing this new page.
The answer is no, loading a new page (location.href, or other methods)
unloads the old page and fires the event, which is then itself
unloaded.
If you want notification of a remote window being closed/unloaded that
is from another domain, I am aware of a couple options:
1. The technique you are currently using (polling from the parent
window).
2. Using a frameset or iframe in the remote window to allow a page from
the same domain to also be loaded into the remote window (but not
visible), on which you can set events. Since all frames get unloaded at
once when the window is closed, this should have the same effect.
I should also mention that if you only care about the remote window
being closed, and you don't want notification when the user navigates
the remote window to a new page (for example, if they click a link in
the remote window), then you will probably want to use the polling
technique or the frameset/iframe technique.