计时器:setInterval(代码,交互时间); <script type="text/javascript"> var attime; function clock(){ var time=new Date(); attime=time.toLocaleTimeString(); document.getElementById("clock").value = attime; } setInterval(clock,1000); </script> 取消计时器clearInterval() <script type="text/javascript"> function clock(){ var time=new Date(); document.getElementById("clock").value = time; } var i = setInterval("clock()",1000); </script> </head> <body> <form> <input type="text" id="clock" size="50" /> <input type="button" value="Stop" οnclick="clearInterval(i)"/> </form> </body>