Tuesday 15 April 2014

javascript - java script setInterval setting the delay? -


We have a case of running a Java script thread once in a month. But what we see is that if we delay 3.5 weeks for the Set Internal Festival, it is not respected and once the scheduling starts getting started. Is this a bug? Is there a maximum limit for delays?

The interesting thing is that setTimeOut works fine -

   & Lt; Script & gt; Var int = setInterval (function () {clock ()}, 1000 * 60 * 60 * 24 * 7 * 3.5); Function clock () {var d = new date (); Var t = d.toLocaleTimeString (); . Document.getElementById ("clock") value = t,} & lt; / Script & gt; & Lt; Button onclick = "int = window.clearInterval (int)" & gt; Stop & lt; / Button & gt; & Lt; / Body & gt; & Lt; / Html & gt;               

  1000 * 60 * 60 * 24 * 7 * 0x80000000 is close, I wonder if the arithmetic signed on 32 may be somewhat responsible.  

I have just defined the specification and setInterval and setTimeout as the long values, which means That 32 bit has been signed. It is unclear how a negativetimeout value will be treated.

Specifically:

Long set timefile (function handler, optional long time, any ... logic);

By standard:

Long type is a signed integer type, in which the values ​​are in the range [2147483648, 2147483647].

I can make two suggestions to fix my problem:

Since setTimeout works, use it and Re-enable at the end of the processing function

Alternatively you want the half-term setInterval and use the toggle to execute your code each time.

No comments:

Post a Comment