JS案例:设置时间提醒器
来自CloudWiki
<!doctype html> <html> <head> <meta charset="utf-8"> <title>使用定时器示例</title> <script type="text/javascript"> function showTime() {//在浏览器状态栏中显示时间 var now=new Date(); //当前时间 alert("当前时间是:"+now.toLocaleTimeString()); } var timerID=window.setInterval("showTime()",5000); //设置一个定时器,每间隔1秒执行一次 showTime() function stopShowTime() {//停止显示时间 window.clearInterval(timerID); //取消定时器 alert("已取消定时器"); } </script> </head> <body> <p><a href="javascript:stopShowTime()">取消定时器</a></p> </body> </html>