The setInterval method can be used to call the function cyclically at a specified interval until the clearInterval method cancels the loop.
When the clearInterval method is used to cancel a loop, you must assign a value to the call of the setInterval method, and then the clearInterval method references the variable.
<Script type = "text/javascript"> n = 0 (n = 1000 + + s = window. setInterval (print, 10 </script>
Use setTimeout and clearTimeout to call latency. After the specified delay time, run the specified function only once. ClearTimeout is used in the same way as clearInterval.
<Script type = "text/javascript"> time = year = month = (time. getMonth () + 1 daynum = hour = min = sec = da = 0: daystr = "Sunday" 1: daystr = "Monday" 2: daystr = "Tuesday" 3: daystr = "Wednesday" 4: daystr = "Thursday" 5: daystr = "Friday" 6: daystr = "Saturday ": daystr = "" str = year + "year" + month + "month" + da + "day" + daystr + "" + hour + ":" + min + ": "+" t "). innerHTML = 1000 </script> <body onload = "printTime ()"> <br/> <div id = "t"> </div> </body>