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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question how know when popup window closes ?

    I'm creating a popup window like this:

    Code:
    var win = window.open(blah blah blah)
    I want to be able to tell in my calling page when the popup window closes, or better yet, when the form on the popup is submitted. I have tried this:

    Code:
    var win = window.open(blah blah blah);
    win.onunload = MyUnloadFunction;
    but it doesn't work; my onunload handler isn't called.

    What am I missing?

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    try this:
    Code:
    // main page:
    function foo(str) {
      alert(str);
    }
    Code:
    // in the popup
    function validate(theForm) {
      // perform validation on your form here
      
      // call to the opening page *after* any validation refusals
      if(opener && !opener.closed) {
        opener.foo("the opener posted a form");
      }
      return true;
    }
    your popup form:
    Code:
    <form name="frm" ..... onsubmit="return validate(this);">
    .....
    </form>
    hope this helps

    m_n
    Last edited by martin_narg; 01-20-2006 at 05:05 PM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    New to the CF scene
    Join Date
    Jan 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow! Thank you.


  •  

    Posting Permissions

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