定时器
setTimeout(fn, time) 返回timer,用于指定一段时间后执行某函数
setInterval(fn,time) 返回timer,用于周期性执行某函数
fn,可以是字符串组成的javascript代码,也可以是一个函数的名称
clearTimeout(timer)函数,清除setTimeout创建的定时器
clearInterval(timer)函数,清除setInterval指定的定时器
setTimeout(fn, time) 返回timer,用于指定一段时间后执行某函数
setInterval(fn,time) 返回timer,用于周期性执行某函数
fn,可以是字符串组成的javascript代码,也可以是一个函数的名称
clearTimeout(timer)函数,清除setTimeout创建的定时器
clearInterval(timer)函数,清除setInterval指定的定时器
function testsetTimeout(){
window.setTimeout("alert(111);", 3000);
}
var timer;
function start(){
timer = window.setInterval("alert(222)", 3000);
}
function stop(){
window.clearInterval(timer);
}