var i = 10,timer=null;
  function test() {
    document.getElementById("<%=Label1.ClientID %>").innerHTML = i--;
    if (i < 0) clearInterval(timer);
  }
  window.onload = function () {
   timer= setInterval("test()", 1000);
  }
http://topic.csdn.net/u/20100803/09/39c84656-952c-4707-95b6-4bedea74d072.html

解决方案 »

  1.   

    请参考我写的那个:http://topic.csdn.net/u/20100803/09/39c84656-952c-4707-95b6-4bedea74d072.html
      

  2.   

    比如,从早上10点倒计时到第二天早上9点,一共23小时:
    <html>
    <head>
    <script>
    function displayCountDown(XelementID, Xdays, Xhours, Xminutes, Xseconds)
    {
    var days = Xdays;
    var hours = Xhours;
    var minutes = Xminutes;
    var seconds = Xseconds;
    if (hours < 10)
    hours = "0" + hours;
    if (minutes < 10)
    minutes = "0" + minutes;
    if (seconds < 10)
    seconds = "0" + seconds;
    var displayValue = "还剩下:" + days + "天" + hours + ":" + minutes + ":" + seconds;
    document.getElementById(XelementID).innerHTML = displayValue;
    var newSeconds = Xseconds - 1;
    var newMinutes = Xminutes;
    var newHours = Xhours;
    var newDays = Xdays;
    if (newSeconds < 0)
    {
    newSeconds = 59;
    newMinutes = Xminutes - 1;
    }
    if (newMinutes < 0)
    {
    newMinutes = 59;
    newHours = Xhours - 1;
    }
    if (newHours < 0)
    {
    newHours = 23;
    newDays = Xdays - 1;
    }
    if (newDays < 0)
    {
    document.getElementById(XelementID).innerHTML = "时间到!";
    return;
    }
     t = setTimeout("displayCountDown('" + XelementID + "'," + newDays + "," + newHours + "," + newMinutes + "," + newSeconds + ")", 1000);
    }
    function checkTime()
    {
        var dt=new Date();
        var hour=dt.getHours();
        var minute=dt.getMinutes();
        var second=dt.getSeconds();
        if(hour==10&&minute==0&&second==0)
            displayCountDown("div1", 0, 23, 0, 0);
        var t=setTimeout("checkTime()",1000);
    }
    </script>
    </head>
    <body>
    <div id="div1"></div>
    <script>checkTime()</script>
    </body>
    </html>
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head><script type="text/javascript">
    var time; //计时器
    var minute = 22;
    var second = 60;
    var showTime =minute + "分" + second + "秒"; //显示时间
     
    function setTime(){
     second--;
     if(second == -1){
      minute--;
      second = 59;
     }
     if(minute == -1){
      hour--;
      minute = 59;
     }
     if((minute == 0) && (second == 0)){
      clearTimeout(time); //清除计时器
     }else{
      showTime =minute + "分" + second + "秒";  
      time = setTimeout('setTime()', 1000);
     }
     document.all("lblTime").innerText = showTime;
    }
    onload = function(){
     document.all("lblTime").innerText = showTime;
     time = setTimeout('setTime()', 1000);
    }
    </script>
    <body>
    <span id= "lblTime"> </span>  
    </body>
    </html>