View Full Version : Trigger action in parent window when child window closes - is it possible?

06-25-2009, 09:18 PM
Hi all

I'm not very experienced with javascript, so please excuse my ignorance.

I want to do something very specific, namely:

Put a link on my page that will open an external site (over which I have no control) in a pop-up window. When the user closes the pop-up, I want my original page to redirect to another page.

The difficulty I'm having is that I can't add any code to the page in the pop-up as it's not my site.

Make sense?

Anyone have any dashed clever solutions?


Philip M
06-26-2009, 09:23 AM
AFAIK it is not possible to detect whether the pop-up has closed as for security reasons JavaScript has no access to the window-array.

Quizmaster: What "U" is a South American country whose capital city is Montevideo?
Contestant: Uganda.

06-26-2009, 05:02 PM
Would this work for a workaround?

What if I create a child page that uses a php include to display the external page - that way I can include javascript in the child page.

what JS would I need to a) launch the popup from a link and then b) redirect the parent page when the child page closes? would i use an onUnload? what syntax would i need?

Philip M
06-26-2009, 05:52 PM
I don't think what you suggest will work. The pop-up body onunload event cannot be passed back to the parent page.

07-02-2009, 07:51 PM
try adding something like this:

functio openNewWindow()

var zWin = window.open(.....);

function winListen(zWin)
//dummy code
while (zWin != null)