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
Post a Comment