JavaScript定时器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>定时器</title>
<script type="text/javascript">
//单次定时(只执行一次)
//setTimeout为javascript内置函数,
//第一项参数为要执行的代码
//第二个参数为延时时间,单位为毫秒
//
setTimeout("alert('哈哈')", 2*60*1000);
//间隔定时器(循环执行)
//setInterval为javascript内置函数
//第一项参数为要执行的代码
//第二个参数为延时时间,单位为毫秒
//
var timeID = setInterval("reload()", 3000); //返回一个setInterval对象的ID
function reload() {
alert('刷新');
location.reload();//重载页面
}
//停止间隔定时器
clearInterval(timeID); //传入setInterval的ID
clearTimeout();//停止单次定时器
</script>
</head>
<body>
</body>
</html>