JS倒计时

<script language="javascript" type="text/javascript">
 var i = 5;
 function fun() {
  if (i == 0) {
   window.location.href = "default.php";
   clearInterval(intervalid);       
  }
  document.getElementById("mes").innerHTML = i;
  i--;
 }
 var intervalid=setInterval("fun()", 1000);
</script>
<span id="mes"></span>
<script language="JavaScript" type="text/JavaScript">
function show_date_time(n){
    var m=n-1;
    if (n==0){
        alert("5分钟到期");
    }else{
       TimeMsg(m,60)
       window.setTimeout("show_date_time("+m+")",1000); //1000表示1秒钟
    }
}
//-------------------------
function TimeMsg(a,b){
 var c=parseInt(a/b); //取整
 var d=a%b //取余
 document.getElementById("nowtime").innerHTML=c+"分"+d+"秒";
}
</script>
<a href="javascript:show_date_time(300);">5分钟到计时测试</a><br /><br />
<a href="javascript:TimeMsg(9,60);">js除法</a><br /><br /><hr />
<hr />
<table width="248" border="0" cellspacing="0" cellpadding="0">
 <tr>
   <td width="108">现在还有:</td>
   <td width="106" bgcolor="#FFCCCC"><div id="nowtime"></div></td>
   <td width="34">秒</td>
 </tr>
</table>  

    A+
发布日期:2009年08月05日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: