javascript - How to setTimeout only 1 time looping? -


how settimeout 1 time looping?

this code looping forever , want loop 1 time.

this code:

<html> <head> <script language="javascript" type="text/javascript"> function dostuff() {     document.myform.submit(); } var mytimer = settimeout(dostuff, 1000); </script> </head> <body> <form name="myform" action="" method="post"> </form> </body> </html> 

every time form submitted, page reloaded , settimeout called again.

you have keep track of page each time it's loaded. example:

sessionstorage.submitted = new date().tostring(); 

and check:

if (!sessionstorage.submitted)     var mytimer = settimeout(dostuff, 1000); 

(note: doesn't work in ie7-.)

by way, what's point in submitting using post static html page? maybe there's php code we're not seeing?


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -