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 Coder
    Join Date
    Aug 2002
    Location
    Vancouver, BC
    Posts
    67
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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
    Last edited by camarosource; 10-12-2003 at 09:39 AM.

  • #2
    New Coder
    Join Date
    Aug 2003
    Location
    Rhondda Cynon Taff, Wales
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think that this is in the wrong forum - havent i seen this post some where else too?
    Ryan Jones(sciguyryan)
    Visit us and chat at our forums - the Kidscript Forums

  • #3
    New Coder
    Join Date
    Aug 2003
    Location
    Rhondda Cynon Taff, Wales
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you could use the tineout function to do that.
    Ryan Jones(sciguyryan)
    Visit us and chat at our forums - the Kidscript Forums

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You could have an onsubmit handler like this:

    Code:
    <form ....onsubmit="openwin(location.href); return true;">
    ...with the openwin() function along the lines of this:

    Code:
    function openwin(loc) {
    var x = window.open();
    x.document.open();
    x.document.write("Please wait, processing.....");
    
    setInterval(function() { if(opener.location.href != loc) x.window.close(); }, 100);
    I *think* that will work.

    Hope that helps!

    Happy coding!

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,968
    Thanks
    0
    Thanked 236 Times in 233 Posts
    put this in the page after form submission:

    <script type="text/javascript">
    var popup = window.open("","nameOfPopup");
    if (popup && !popup.closed) popup.close();
    </script>

    That will do the trick. Just specify the same target name used in opening the popup in the previous page.


  •  

    Posting Permissions

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