全数位的倒计时设计:01:30:00  --->   00:00:01 请赐教!谢谢。

解决方案 »

  1.   

    <html>
     <head>
       <meta http-equiv="content-type" content="text/html;charset=gb2312" />
       <title>记时器</title>
       <script src="timer.js" type="text/javascript"></script>
     </head>
     <body>
    <div id="div1"></div>
    <div id="div2"></div>
    <div id="div3"></div>
    <script type="text/javascript">
    //==========生成记时器,注意生成实例要在你的对象下面,要不会提示“请设置要显示时间的对象!”的错误
    new Timer(1,30,0,"div1")
    new Timer(0,2,0,"div2")
    new Timer(0,0,30,"div3")
    </script>
    </body>
    </html>/*
      timer.js
            ---Edit By ShowBo
    */
    //===========辅助函数
    function FormatNumber(Num){if(Num<10)return "0"+Num;else return Num.toString();}
    function $(Id){if(typeof(Id)=="string")return document.getElementById(Id);else return Id;}
    //===========
    function Timer(hour,minute,second,ObjId)
    {
      var PackUp=this;
      this.hour=hour;
      this.minute=minute;
      this.second=second;
      this.obj=$(ObjId);
      if(!this.obj)
      {
        alert("请设置要显示时间的对象!")
        return;
      }  
      this.obj.innerHTML=FormatNumber(this.hour)+":"+FormatNumber(this.minute)+":"+FormatNumber(this.second);
      if(hour<1&&minute<1&&second<1)
      {
        alert("此记时器无效!");
        return;
      }
      this.Go=function()
      {
        if(this.hour<1&&this.minute<1&&this.second<1)
        {
          clearInterval(this.timer);
          this.timer=null;
          alert(ObjId+"记时完成!");
          return;
        }
        this.second--;
        if(this.second<1)
        {
          if(this.minute>0)
          {
           this.second=59;
           this.minute--;
          }
          else if(this.hour>0)
          {
            this.minute=59;
            this.hour--;
          }
        }
        
        this.obj.innerHTML=FormatNumber(this.hour)+":"+FormatNumber(this.minute)+":"+FormatNumber(this.second);
      }
      this.timer=setInterval(function(){PackUp.Go();},1000);  
    }
      

  2.   

    http://topic.csdn.net/u/20080526/16/67d993af-5c8f-4767-b9fb-1a47df2d0174.html?seed=237871488
      

  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> 
    <script type="text/JavaScript"> 
     var lastMinutes=59;
     var lastSeconds=60;
     var t,stingTime;
     function showTime(){
     document.getElementById("hehe").disabled=true;
     var allTime=60*60*1000;
     lastSeconds--;
     if(lastSeconds==0 && lastMinutes==0){
        clearTimeout(t);
        return;
     }
    else  if(lastSeconds<0){
         lastSeconds=59;
        lastMinutes--;
     }
     
     stringTime="还剩时间为:"+lastMinutes+" : "+lastSeconds;
     document.getElementById("timeDiv").innerHTML=stringTime;
      setTimeout(showTime,1000);
    }
    </script> </head> 
    <body> 
    <input type='button' value='开始考试' onclick='showTime();' id='hehe'>
    <div id='timeDiv'></div>
     </body> </html>
      

  4.   

    http://download.csdn.net/source/322576#acomment
    这里有我写过的计时器的程序,是个自动关机程序。大家用用看看,C++写的。不过源代码格掉了,这个也是当初考给我弟弟用的,才得以保留下来。是我写的第一个图形化程序. 其中计时器,没用到任何现成函数,是定义了h,m,s等变量来实现计时的,小时h我只定了了最大不能超过24。     另外还有一个问题,就是这个程序调定了时间什后,不能按回车否则跳掉,只能用鼠标点。这是当初没有定义的问题。后才才想起。