js實現考試倒計時


<html>

   <head>
   </head>

   <body>
      <input type="text" name="mss" id="mss"/>
      
      <form action="./index.html">
        <input type="text" value="name" name="name"/>   

     </form>
 
   <body>

</html>


<script type="text/javascript">
<!--
   window.onload=function(){
     
        daojishi();
     }

      var counttime=90*60;//總秒鍾
     
      function daojishi(){
      if(counttime>=0){
             var ms = counttime%60;//余數 89%60==29秒
             var mis = Math.floor(counttime/60);//分鍾
             if(mis>=60){
              var hour=Math.floor(mis/60);

     mis=Math.floor((counttime-hour*60*60)/60);

              document.getElementById("mss").value=hour+"小時"+mis+"分"+ms+"秒數";
             }else if(mis>=1){
              document.getElementById("mss").value=mis+"分"+ms+"秒數"; 
             }else{
              document.getElementById("mss").value=ms+"秒數"; 
             }

   
              counttime--;
              vartt =  window.setTimeout("daojishi()",1000);
   }else{
       window.clearTimeout(vartt);
       window.confirm("考試時間結束,請單擊提交"); 
       tijiao();
      
   }

   
     }
     
     function tijiao(){
        document.forms[0].submit();
     }
//-->
</script>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM