我也试试,老师指教一下
<html>
<head>
<script type="text/javascript">
function $(selector){
    return document.getElementById(selector);
}
(function(){
    var index = 0;
    var timer = null;    $.show = function (){
        var d1 = $("d1"), d2 = $("d2");
        timer = setInterval(loading,100);
        function loading(){
            if(index>=100){ clearInterval(timer); return;}
            d1.style.width = ++index + "%";
            d2.innerHTML = "已加载" + index + "/100";
        }
    }
    $.end = function (){
        if(timer){
            clearInterval(timer);
        }
    }
})();
</script>
</head>
<body>
  <div style="border:1px blue solid;width:800px;height:25px">
  <div style="width:0px;height:23px;background-color:#FF99CC" id="d1"></div>
  </div>
  <div id="d2" style="font-size:9pt"> </div>  <input type="button" value="开始" onclick="$.show();">
  <input type="button" value="结束" onclick="$.end();">
</body>
</html>
<script type="text/javascript">
<!--
var count = 0;
var timer = 0;
function $(selector){
    return document.getElementById(selector);
}
function begin(){
    var ipt= $("time");
    timer = setInterval(output,1);
    function output(){
        count++;
        ipt.value = [Math.floor(count/3600),Math.floor((count%3600)/60),count%60].join(':').replace(/(^|:)(\d)(?=\D|$)/g,'$10$2');
    }
}
function pause(){
    if(timer) clearInterval(timer);
}
function reset(){
    pause();
    var ipt= $("time");
    ipt.value = '00:00:00';
    count = 0;
}
//-->
</script>
<body>  
<input type="text" id="time" value="00:00:00"/> 
<input type="button" value="开始" onClick="begin()" /> 
<input type="button" value="暂停" onClick="pause()" /> 
<input type="button" value="重置" onClick="reset()" />
</body> 

解决方案 »

  1.   

    还有教这的啊 
    我上学那会老师只会对着书狂练 没做个一个象样程序
    大多程序就是 printf羡慕啊
      

  2.   

    进度条--小问题--连续点击“加载”--速度递增,
    小改^_^<html> 
    <head> 
      <script type="text/javascript"> 
      var index = 0; 
      var flag=null;   function show(obj){ 
        if (!flag)
         flag = window.setInterval("add()",100); 
      }   function add() { 
        if(index >= 800){
          window.clearInterval(flag);
        }
        else {
          index += 4; 
          document.getElementById("d1").style.width = index + "px"; 
          document.getElementById("d2").innerHTML = "已加载" + parseInt((index/800)*100) + "/100"; 
        } 
      } 
      </script> 
    </head> 
    <body> 
      <div style="border:1px blue solid;width:800px;height:25px"> 
      <div style="width:0px;height:23px;background-color:#FF99CC" id="d1"> </div> 
      </div> 
      <div id="d2" style="font-size:9pt"> </div>   <input type="button" value="加载" onclick="show(this);"> 
    </body> 
    </html> or:<html> 
    <head> 
      <script type="text/javascript"> 
      var index = 0; 
      var flag;   function show(obj){ 
        obj.disabled=1
        flag = window.setInterval("add()",100); 
      }   function add() { 
        if(index >= 800)
          window.clearInterval(flag); 
        else {
          index += 4; 
          document.getElementById("d1").style.width = index + "px"; 
          document.getElementById("d2").innerHTML = "已加载" + parseInt((index/800)*100) + "/100"; 
        } 
      } 
      </script> 
    </head> 
    <body> 
      <div style="border:1px blue solid;width:800px;height:25px"> 
      <div style="width:0px;height:23px;background-color:#FF99CC" id="d1"> </div> 
      </div> 
      <div id="d2" style="font-size:9pt"> </div>   <input type="button" value="加载" onclick="show(this);"> 
    </body> 
    </html> 
      

  3.   

    秒表--小问题--连续点击“加载”--速度递增, 
    小改^_^<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 1</title>
    </head><script language="javascript" type="text/javascript"> 
      var x=0; 
      var y=0; 
      var z=0; 
      var aa=null; 
    function ontime() { 
      document.getElementById("time").value = x + ":"+ y + ":" + z; 
      if(event.srcElement.value =="暂停"){
      window.clearInterval(aa);
      aa=null; 
      }
      else if(event.srcElement.value =="开始"){
      if (!aa)
      aa = window.setInterval(add, 10); 
      } 

    function add() 

        if(z < 99) 
      { 
        z=z+1; 
        //alert(z); 
      } 
      else if(y < 59) 
      { 
        y+=1; 
        z = 0; 
      } 
      else 
      { 
      x += 1; 
      y = 0; 
      z = 0; 
      } 
      document.getElementById("time").value = x + ":"+ y + ":" + z; 

    function stop() 

      window.clearInterval(aa); 

    </script> 
    <body>  
    <input type="text" value="" id="time" /> 
    <input type="button" value="开始" onClick="ontime()" /> 
    <input type="button" value="暂停" onClick="ontime()" /> 
    </body> </html>
      

  4.   

    ksk 呵呵! 路过, 看看老师代码!   嘿!