<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>js15.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> <script type="text/javascript"> var sec = 0; var timeId = setInterval("count();", 1000); function count() { document.getElementById("num").innerHTML = sec++; } function stopCount() { clearInterval(timeId); } </script> </head> <body> <font color="red" id="num">0</font>秒钟 <input type="button" value="停止" onclick="stopCount();"> </html>
各种javascript时间问题,可以参考此处。。。