The timer MUST be familiar to everyone. In this article, we will introduce in detail how to implement the timer in js. The specific principle and code are as follows. Do not miss it if you are interested.
The Code is as follows:
$ (Function (){
Var handler = function (){
}
Var timer = setInterval (handler, 1000 );
Var clear = function (){
ClearInterval (timer );
}
});
I want to add a page Jump in the timer and load the timer when loading the page. How to write it?
The implementation is like how many messages are prompted at the place where Baidu initiates instant messages. The method for querying the number of items in java is available. How to Write JavaScript?
Timer:
It is used to execute a program after a specific period of time.
Regular execution in JS, difference between setTimeout and setInterval, and l release method
SetTimeout (Expression, DelayTime): After DelayTime, an Expression is executed. setTimeout is used for a delay period before a certain operation.
SetTimeout ("function", time) sets a timeout object
SetInterval (expression, delayTime). Expression is executed for each DelayTime. It is often used to refresh an expression.
SetInterval ("function", time) sets a timeout object
SetInterval indicates automatic repetition, and setTimeout does not.
ClearTimeout (object) clears the set setTimeout object
ClearInterval (object) clears the set setInterval object
The Code is as follows:
SetTimeout (aa (), 1000) // unit: milliseconds
Function aa ()
{
Location. href ('address ');
}