I have asked this question before and the problem was half solved in the sense I was helped to find out that Javascript has some tough security in place.
What I learnt: A parent Window opens a child window. The child window redirects to a different domain and gets redirected back. It attempts to fire off a function of the parent window upon closing itself.
window.opener.startLoad();
This leads to a permissions (security) problem and will not work.
(Half) New Problem: How can I get a window to open a child window and when it closes run a function in the parent window?
I need a very efficient way of doing this as this will be happening a lot!
Thank you for any help.
Try this:
All this code would be located and executed in the parent window’s javascript (including afterChildClose()). You are creating the window and assigning the function to the unload event.
Oh, one thing I just thought of. If the child window refreshes or navigates to another url, the onunload event will fire as well. If you only want the event to fire when the window is closed, you should include a check in afterChildClose() on win.closed.
EDIT: Here is the code to two sample pages I put together to try this out.
Parent window:
child window (“secondwindow.html”):
When I try opening the first document in firefox, it opens the window, the window waits 5 seconds and quits, and the first document shows the alert(), so it is working even when the sub window closes itself.