Results 1 to 2 of 2

Thread: javascript on window close

  1. #1
    Join Date
    Dec 2008
    Location
    Fremont, CA
    Posts
    30
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default javascript on window close

    To many here, this would be a simple issue, but am new to Javascript and I dont knw how to go about it.

    This is what i have:

    a) A window pops up from a page, and user does some posting/uploading/adding operations(PHP), all involve refreshing this newly opened window.

    what i want is , when the user closes this new pop up window(by clicking on the RED 'X' at the top) i want the parent window to be refreshed.

    This is what i have(new pop up window) :

    PHP Code:
    <script>
    function 
    ref(){
    window.opener.location.reload(true);
    window.close();
    }
    </script>
    <body onunload="ref()">
    </body> 
    This is wht i want, but the problem is , everytime the child window refreshes, child window gets closed and the parent window is refreshed. I want this 'close and refresh' behavior to happen only when the window is closed(through the RED X at the top right of the window ONLY).

    Any help would be great.

    Best,
    Kris

  2. #2
    Join Date
    Dec 2008
    Location
    Fremont, CA
    Posts
    30
    Thanks
    1
    Thanked 7 Times in 7 Posts

    Default

    Ok, found the fix. The fix is to simply remove the
    window.close(); line.!!

Bookmarks

Posting Permissions

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