您的位置:首页 > Web前端 > JavaScript

倒计时js

2008-08-06 12:16 387 查看
<html>
<head><title></title></head>
<script type ="text/javascript" >
function GetRTime(){
var EndTime= new Date(2008,07,08,20,00); //截止时间:2008年8月8日20时0分
var NowTime = new Date();
var nMS =EndTime.getTime() - NowTime.getTime();
var nD =Math.floor(nMS/(1000 * 60 * 60 * 24));
var nH=Math.floor(nMS/(1000*60*60)) % 24;
var nM=Math.floor(nMS/(1000*60)) % 60;
var nS=Math.floor(nMS/1000) % 60;
if(nD>= 0){
document.getElementById("RemainD").innerHTML=nD+"天";
document.getElementById("RemainH").innerHTML=nH+"小时";
document.getElementById("RemainM").innerHTML=nM+"分钟";
document.getElementById("RemainS").innerHTML=nS+"秒";
}
else {
document.getElementById("CountMsg").innerHTML="奥运会开幕式!";
}
setTimeout("GetRTime()",1000);
}
window.onload=GetRTime;
</script>
<body>
<table><tr>
<td id="RemainD"></td>
<td id="RemainH"></td>
<td id="RemainM"></td>
<td id="RemainS"></td>
<td id="CountMsg"></td>
</tr></table>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: