使用JS实现倒计时(在页面上动态的显示)

来源:互联网 发布:淘宝卖家消失了咋整 编辑:程序博客网 时间:2024/05/17 03:03

 <SCRIPT language=JavaScript>
<!--
var maxtime;

maxtime = 60*60;

function CountDown(){
if(maxtime>=0){
minutes = Math.floor(maxtime/60);
seconds = Math.floor(maxtime%60);
msg = ""+minutes+"分"+seconds+"秒";
document.all["timer"].innerHTML = msg;
if(maxtime == 20*60) alert('注意,还有4分钟!");
if(maxtime == 2*60) alert('注意,还有2分钟!");
 
if(maxtime == 1*60) alert('注意,还有1分钟!");

--maxtime;
window.name = maxtime;

}
timer = setInterval("CountDown()",1000);
//-->
                  </SCRIPT>
</head>
<body>
<br>
<span id=timer></span>