How to write js timer? This is the execution of a program at a particular time
- 2020-03-26 21:20:11
- OfStack
$(function(){
var handler = function(){
}
var timer = setInterval( handler , 1000);
var clear = function(){
clearInterval(timer);
}
});
I'm going to add a page jump in the timer, and then load the timer when the page loads. How do I write that?
What should realize is like the place that initiates instant message above baidu prompt how many messages. I have a method for querying the number of bars in Java. How do you write js?
Timer:
Used to specify the execution of a program after a specified period of time.
JS timing execution,setTimeout and setInterval differences, and l unwinding method
SetTimeout (Expression,DelayTime). After DelayTime, an Expression and a setTimeout will be executed for a delay of some time, and then an operation will be performed.
SetTimeout ("function",time) sets a timeout object
SetInterval (expression,delayTime), each delayTime, will execute expression. Often used to refresh expressions.
SetInterval ("function",time) sets a timeout object
SetInterval repeats automatically. SetTimeout does not repeat.
ClearTimeout (object) clears the setTimeout object that has been set
ClearInterval (object) clears the setInterval object that has been set
setTimeout(aa(),1000) //Unit of milliseconds
function aa()
{
location.href(' address ') ;
}