<html lang="en">
<head>
<meta charset="utf-8">
<title>倒计时</title>
<script type="text/javascript">
function init(){
cutdowns("a",3605);
}
function cutdowns(divId,value){
var h=0;
var m=0;
var timer = window.setInterval(function(){
value--;
var s=parseInt(value);
if(s>=60){
m=parseInt(s/60);
s=parseInt(s%60);
}else{
m=parseInt(s/60);
}
if(m>=60){
h=parseInt(m/60);
m=parseInt(m%60);
}else{
h=parseInt(s/3600);
}
var result=myFormat(h,m,s);
document.getElementById(divId).innerHTML=result;
if(value==0){
window.clearInterval(timer);
}
},1000);
}
function myFormat(hour,min,sec){
if(hour<10){
hour="0"+hour;
}
if(min<10){
min="0"+min;
}
if(sec<10){
sec="0"+sec;
}
return hour+":"+min+":"+sec;
}
</script>
</head>
<body onload="init()">
<div id="a">asdf</div>
</body>
</html>
先贴代码为敬。根据秒数进行时间格式的调整并进行倒计时。