我是靠谱客的博主 精明飞鸟,最近开发中收集的这篇文章主要介绍javascript页面倒计时实例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

本文实例讲述了javascript页面倒计时实现方法。分享给大家供大家参考。具体实现方法如下:

<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=120*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>

希望本文所述对大家的javascript程序设计有所帮助。

最后

以上就是精明飞鸟为你收集整理的javascript页面倒计时实例的全部内容,希望文章能够帮你解决javascript页面倒计时实例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(127)

评论列表共有 0 条评论

立即
投稿
返回
顶部