js代码倒计时

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
  <title>js倒计时代码 - k686绿色软件 - http://www.k686.com</title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="k686绿色软件 http://www.k686.com">
  <meta name="Keywords" content="绿色软件">
  <meta name="Description" content="绿色软件">

</head>

<body>
k686绿色软件 - http://www.k686.com
<script>
function countDown( maxtime,fn )
{   
   var timer = setInterval(function()
   {
   if(maxtime>=0){  
minutes = Math.floor(maxtime/60);  
seconds = Math.floor(maxtime%60);  
msg = "距离结束还有"+minutes+"分"+seconds+"秒";  
fn( msg );
if(maxtime == 5*60) alert('注意,还有5分钟!');  
--maxtime;  
}  
else{  
clearInterval( timer );
fn("时间到,结束!"); 
}  
}, 1000);
}
</script>

<div id="timer1" style="color:red"></div>
<div id="timer2" style="color:red"></div>

<script>
countDown( 6,function( msg )
{
document.getElementById('timer1').innerHTML = msg;
});

countDown( 6000,function( msg )
{
document.getElementById('timer2').innerHTML = msg;
})
</script>
</body>
</html>

你可能感兴趣的:(html)