Nonove js timer 计时器

<html> 
<head> 
<title> Nonove js timer 计时器 </title> 
</head> 
<body> 
<script language="javascript"> 
var se,m=0,h=0,s=0,ss=1; 
function second(){ 
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;} 
t=h+""+m+""+s+""+ss+"毫秒"; 
document.getElementById("showtime").value=t; 
ss+=1; 
} 
function startclock(){se=setInterval("second()",1);} 
function pauseclock(){clearInterval(se);} 
function stopclock(){clearInterval(se);ss=1;m=h=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 name="showtime" style="color:#ff0000;width:200px;" id="showtime" type="text" value="0时0分0秒"> 
</body> 
</html> 

 

posted @ 2014-08-10 10:05  商商-77  阅读(172)  评论(0编辑  收藏  举报