<!DOCTYPE?html>
<html>
????<head>
????????<meta?charset="UTF-8">
????????<title></title>
????</head>
????<body>
????????<script?type="text/javascript">
????????????var?se,h=0,m=0,s=0,ss=1;
????????????function?time_show(){
????????????????if((ss%100)==0)?{s+=1;ss=1;}
????????????????if(s>0?&&?(s%60)==0)?{m+=1;s=0;}
????????????????if(m>0?&&?(m%60)==0)?{h+=1;m=0;}
????????????????var?t=h+"時"+m+"分"+s+"秒"+ss+"毫秒";
????????????????document.getElementById("showTime").value=t;
????????????????ss++;
????????????}
????????????function?startclock()?{se=setInterval("time_show()",10);}
????????????function?pauseclock()?{clearInterval(se);}
????????????function?stopclock()?{clearInterval(se);ss=1;h=m=s=0;}
????????</script>
????????<input?name="s"?type="button"?value="開始計時"?onclick="startclock()"?/>
????????<input?name="s"?type="button"?value="暫停計時"?onclick="pauseclock()"?/>
????????<input?name="s"?type="button"?value="停止計時"?onclick="stopclock()"?/>
????????<input?type="text"?id="showTime"?value="0時0分0秒0毫秒"?/>
????</body>
</html>為什么多次按“開始計時”按鈕后,計時速度會加快,而且不能暫停計時了,這是怎么回事?
用javascript編寫的一個計時器的一個BUG
Best_4
2016-04-08 10:53:44