欢迎访问我的博客 https://javascript.shop

显示倒计时,为零时自动点击按钮提交【JavaScript实现】

原文发布时间为:2008-10-17 —— 来源于本人的百度文章 [由搬家工具导入]

<html>
<head>
<title>显示倒计时,完毕提交</title>
<script language="JavaScript">      
function   testTime()   {  
      if(sec==-1){
             min--;
        if(min!=-1)
             sec=59;
        else
           document.getElementById("button1").click();
      }           
      if(sec>=0)
           document.getElementById("showTime").innerHTML = "<font color=red>"+timeFormat

(min)+" : "+timeFormat(sec)+"</font>";   
      sec--;
}

function timeFormat(time){
     if(time<10)
         return "0"+time;
     else
         return time;
}

function showTime(){
      if(document.all)
setInterval("testTime()",1000);
}
</script>
</head>
<body onload="min=1;sec=12;showTime()">
<span   id="showTime"></span>
<br></br>
<button id="button1" OnClick=alert('时间到,自动提

交!');window.location.href="http://www.baidu.com">提交</button>
</body>
</html>

posted @ 2017-07-11 00:33  孑孓子  阅读(384)  评论(0编辑  收藏  举报
欢迎访问我的博客 https://javascript.shop