Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q546 Why must I set a timeout delay when submitting a form before closing the window - what is this delay accomplishing?

You are here: irt.org | FAQ | JavaScript | Timeout | Q546 [ previous next ]

<form onSubmit="setTimeout('window.close',5000)">
<input type="submit" value="Close Window">
</form>

Because JavaScript has no way of knowing when the form has finished beinging submitted - therefore a guesstimate of the amount of time required for the form submit is chosen (5 seconds) and a time is set up to close the window after 5 seconds has passed. However, on a slow day the form may still not have been submitted within the 5 seconds, the closing of the window will interrupt the form submission and it will fail.

Feedback on 'Q546 Why must I set a timeout delay when submitting a form before closing the window - what is this delay accomplishing?'

©2018 Martin Webb