动态时间

来源:互联网 发布:淘宝装修350会更新吗 编辑:程序博客网 时间:2024/05/16 01:22

 <html>

    <head>
    <title>动态时间效果</title>

    
     <script type="text/vbscript">
        
         dim t
   t=null
   
              s=0
             function setTime()
               
    
       document.Forms("time").days.value=Cstr(Date)
       document.Forms("time").times.value=Cstr(FormatDateTime(Now,3))
    s=s+1
    m=s/60
                if m=0 Then
         s1=s
       Else
         s1=Cint(s-m*60)
    End If

                document.Forms("time").cs.value = Cstr( m&"分钟"&s1&"秒")
                t=setTimeout("setTime()",1000)//这里的setTimeOut("setTime()"
      //t = setInterval("setTime()",10000)
              //clearTimeout(t)'要形成动态的效果,不能加上这条语句,要在外面使用
      
   End function

            function stop2()
                   //alert("asd")
                   window.clearTimeOut(t)
                   //document.all("reset").style.visibility = "visible"
       //document.all("stop").style.visibility = "hidden"
       document.Forms("time").stops.disabled=true
       document.Forms("time").resets.disabled=false
   End function


          function reSetTime(t)
              
      window.clearTimeOut(t)
              
               t=setTimeout("setTime()",1000)//这里的setTimeOut("setTime()"
               // document.all("reset").style.visibility = "hidden"
      document.Forms("time").resets.disabled=true
      document.Forms("time").stops.disabled=false
    End function
   
    </script>
    
   
                         
       
     

 </head>

 <body onload="setTime()">
       
          <form name="time">
      <table >
         <tr><td align="right">今天是:</td><td><input readonly type="text" name="days"></td></tr>

         <tr><td align="right">当前时间为:</td><td><input readonly type="text" name="times" /></td></tr>
      <tr><td align="right">您已登录:</td><td><input readonly type="text" name="cs" /></td></tr>
   
               <!-- <input type="submit" name="button" value="show" onclick="setTime()"/>-->
      <tr><td><span id="stop" style="visibility:visible" ><input type="button" name="stops" value="停止" onclick="stop2()"></span></td><td><span id="reset" ><input type="button" value="重启" name="resets" onclick="reSetTime(t)" disabled="true"></span></td></tr>
    

            </table>
       
    </form>
   
                     

 </body>

</html>

原创粉丝点击