Online Shopping : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

64 of 93 people (69%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Why a opened popup window can't submit a form and then close itself? If I comment the close sentence, the submit runs

Apr 4th, 2008 21:06
ha mo, Arsen Yeremin, Juergen Thelen, Néstor Palacios,


I guess you do a .submit(), almost immediately followed by a .close().
If so, you got trapped by the asynchronous behaviour of the .submit() 
method. That is, JavaScript will just invoke your submission, but not 
wait until the submission is finished. Instead it will continue with 
the next line in your script.
If one of these next lines is a window.close() all running/pending 
transmissions are immediately canceled, even your form submission, if 
not already finished...
Usually a short delay of a few seconds will help. Use
 setTimeout(window.close(), TimeToWaitInMilliseconds)
for example.
Hth, Juergen
++++++++++++++++++++++++++++++++++++++++++++++++++++
Another solution would be is to put a 
<script language=”javascript”>
window.close()
</script>
on the page you are submitting to.
That way if they are on a slow connection, or the submit takes longer 
than expected the window will close on completion of the submit.
Arsen Yeremin
++++++++++++++++++++++++++++++++++++++++++++++++++++
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com