日期:2014-05-18  浏览次数:20778 次

JS高手请进
我现在做的是一个倒计时页面,倒到指定的时间停不了(也就是剩0秒了),它还接着倒。
以下是我的JS代码:
<html>  
<head>  
<title> ??? </title>  
<body>  
<script   language=JavaScript>  

var   now   =   new   Date();  
var   year=now.getFullYear();
var   month=now.getMonth()+1;
var   day=now.getDate();

     
function   GetServerTime()  
{  
var   urodz   =   new   Date(month+ "/ "+day+ "/ "+year+ "   <%=request.getAttribute( "endtime ")%> ");  

now.setTime(now.getTime()+250);  
hours   =   (urodz   -   now)   /   1000   /   60   /   60   ;  
hoursRound   =   Math.floor(hours);  
minutes   =   (urodz   -   now)   /   1000   /60     -   (60   *   hoursRound);  
minutesRound   =   Math.floor(minutes);  
seconds   =   (urodz   -   now)   /   1000     -   (60   *   60   *   hoursRound)   -   (60   *   minutesRound);  
secondsRound   =   Math.round(seconds);  

document.getElementById( "time ").innerHTML   =   hoursRound   +   ": "   +   minutesRound   +   ": "   +   secondsRound;  
}  
setInterval( "GetServerTime() ",250);  
</script>  

??********?? <span   id= "date "> </span>   <span   class= "white14b "> ? </span>   <span   id= "time "> </span>  
</body>  
</html>

求高手帮忙改为到0停,跳转到另一个页面。谢了!

------解决方案--------------------
SetTimeOut()