js倒计时

<SCRIPT LANGUAGE="JavaScript">   
<!--   
var maxtime = 60*60 //一个小时,按秒计算,自己调整!   
function CountDown(){   
if(maxtime>=0){   
minutes = Math.floor(maxtime/60); 
while(minutes>=60){
	minutes = Math.floor(minutes-60); 
}  
seconds = Math.floor(maxtime%60); 
hour = Math.floor(maxtime/3600);  
msg = "<span id='RemainD'>"+hour+"</span>小时<span>"+minutes+"</span>分钟<span>"+seconds+"</span>秒";   
document.all["timer"].innerHTML=msg;   
if(maxtime == 5*60) alert('注意,还有5分钟!');   
--maxtime;   
}   
else{   
clearInterval(timer);   
alert("时间到,结束!");   
}   
}   
timer = setInterval("CountDown()",1000);   
//-->   
</SCRIPT>   
<div id="timer" style="color:red"></div>

 

评论关闭