SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2002
    Location
    Burnaby, BC
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help: How to auto close pop up when finished.

    We want to have it so when a HTML form is submitted (a person is uploading a picture) that a Javascript will open a pop up window and then automatically close the window once the file is sent sucessfully.

    See, we use like it's w = window.open(blah blah to open and w.close() to close but when the form is submitted w gets destroyed, so we need a way to close it without w or pass w to the next page or need a way for the popup to check when form is done submitting so it can close itself

    Does anyone know a good way to do this?

    Thanks

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var w = window.open('some url' , 'thingy' , '.........');
    Then, from some other execution context:
    Code:
    var oWindow = window.open('' , 'thingy');
    if (oWindow && !oWindow.closed) oWindow.close();
    ::: certified wild guess :::

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... or need a way for the popup to check when form is done submitting so it can close itself ...
    Here's an idea:
    In the main window 'w' will continue to exist until the page is loaded with the result of the submission at which point 'w' will cease to exist. So, in the popup code try something like this:
    Code:
    <html>
    <head>
    <script>
    pollOpener();
    function pollOpener() {
      if (!window.opener || !window.opener.w) {
        window.close();
      }
      else {
        setTimeout('pollOpener()', 500); // set whatever interval you want
      }
    }
    </script>
    </head>
    <body>
    ...
    </body>
    </html>


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
  •