SetTimeout SetInterval
2009-03-02 15:06
363 查看
setTimeout only one time, so need recursion. So continues running the function one after one
SetInterval continues running, without stoping, and it runs every intervals, without waiting the former stops.
1. SetTimeout
function showTime()
{
var today = new Date();
alert("The time is: " + today.toString());
setTimeout("showTime()", 5000);
}
2. SetInterval
var intervalProcess = setInterval("showTime()", 5000);
function showTime()
{
var today = new Date();
alert("The time is: " + today.toString());
}
clearInterval(intervalProcess);
SetInterval continues running, without stoping, and it runs every intervals, without waiting the former stops.
1. SetTimeout
function showTime()
{
var today = new Date();
alert("The time is: " + today.toString());
setTimeout("showTime()", 5000);
}
2. SetInterval
var intervalProcess = setInterval("showTime()", 5000);
function showTime()
{
var today = new Date();
alert("The time is: " + today.toString());
}
clearInterval(intervalProcess);
相关文章推荐
- setTimeout/setInterval
- 让JavaScript中计时器setTimeout/setInterval的回调方法支持参数传递
- session-timeout(web.xml)元素与session.setMaxInactiveInterval()函数
- Juqery 定时器 settimeout setInterval
- setTimeout/setInterval 传参
- 定时器 setInterval setTimeout
- 【转】javascript setTimeout setInterval 使用详解
- JS setTimeout setInterval
- JS setInterval setTimeout的用法
- setinterval settimeout区别
- setInterval & setTimeout
- 【javascript基础】【setTimeout setInterval】 之 How JavaScript Timers Work [译]
- JavaScript Timers with setTimeout and setInterval
- setTimeout & setInterval
- what is the difference between the setTimeout and setInterval
- js中setInterval/clearInterval与setTimeout/clearTimeout
- setTimeOut setInterval clearTimeOut
- Javascript 调度: setTimeout and setInterval
- web.xml中的session-timeout元素与session.setMaxInactiveInterval()函数 的区别和使用
- setInterval/setTimeout 中this无效