一个不错的js html页面倒计时可精确到秒
一个不错的jshtml页面倒计时可精确到秒,很简单,但和实用
<!doctypehtml> <html> <head> <metacharset="utf-8"> </head> <body> <DIVid="CountMsg"class="HotDate"> <spanid="t_d">00天</span> <spanid="t_h">00时</span> <spanid="t_m">00分</span> <spanid="t_s">00秒</span> </DIV> <scripttype="text/javascript"> functiongetRTime(){ varEndTime=newDate('2014/10/2310:00:00');//截止时间 varNowTime=newDate(); vart=EndTime.getTime()-NowTime.getTime(); /*vard=Math.floor(t/1000/60/60/24); t-=d*(1000*60*60*24); varh=Math.floor(t/1000/60/60); t-=h*60*60*1000; varm=Math.floor(t/1000/60); t-=m*60*1000; vars=Math.floor(t/1000);*/ vard=Math.floor(t/1000/60/60/24); varh=Math.floor(t/1000/60/60%24); varm=Math.floor(t/1000/60%60); vars=Math.floor(t/1000%60); document.getElementById("t_d").innerHTML=d+"天"; document.getElementById("t_h").innerHTML=h+"时"; document.getElementById("t_m").innerHTML=m+"分"; document.getElementById("t_s").innerHTML=s+"秒"; } setInterval(getRTime,1000); </script> </body> </html>