...

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



tomdowler
06-25-2009, 08: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?

Thanks
Tom

Philip M
06-26-2009, 08: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.

tomdowler
06-26-2009, 04: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, 04: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.

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

functio openNewWindow()
{

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

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

redirectToOtherPage();
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum