At javascritp, there are two special about timer function, they are:
1. Counting down the number of seconds timer : timename = setTimeout ( "function ();", delaytime);
2. Cycle timer: timename = setInterval ( "function ();", delaytime);
Countdown timer is triggered after a specified time case, and the cycle timer is at repeated intervals when the arrival of trigger events, the difference is: the role of the former only once, while the latter the role of non-stop.
Countdown timer on the page is generally used only once required to trigger the situation, such as clicking a button at a certain time after the page Jump to the corresponding sites, can also be used to determine whether a viewer you are not on the site of the "old off ", if not, you can be at 5 or 10 seconds after the second Jump to the corresponding site, and then later told him in a certain place by a certain button to enter the Express.
Sometimes we also want to remove some of the timer to add at this time can be used clearTimeout (timename) to turn off the countdown timer, and use clearInterval (timename) to turn off the cycle timer.
setTimeout ( "confirm ('123456 ')", 1000);
function count () (
setTimeout ( "alert ( 'three seconds to the')", 3000)
Sometimes, we want to remove a timer, like the cycle timer is always kept the sport. Can be used clearTimeout (timename) to remove the setTimeout () timer, and setInterval () is used clearInterval (timename) to remove.
clearInterval (): terminate the timer. clearInterval (timer object name)