Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trigger action in parent window when child window closes - is it possible?

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,030
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,030
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    I don't think what you suggest will work. The pop-up body onunload event cannot be passed back to the parent page.

  • #5
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    try adding something like this:

    functio openNewWindow()
    {

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

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

    redirectToOtherPage();
    }


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •