การนับถอยหลังของหน้า JS HTML ที่ดีสามารถแม่นยำถึงวินาทีซึ่งง่าย แต่ใช้งานได้จริง
<! doctype html> <html> <head> <meta charset = "utf-8"> </head> <body> <div id = "countmsg"> <span id = "t_d"> 00 วัน </span> <span id = "t_h"> 00 ชั่วโมง </span> วินาที </span> </div> <script type = "text/javascript"> ฟังก์ชั่น getRtime () {var endtime = วันที่ใหม่ ('2014/10/23 10:00:00'); // กำหนดเวลา var nowtime = date ใหม่ (); var t = endtime.getTime () - nowtime.getTime (); /*var d = math.floor (t/1000/60/60/24); t- = d*(1,000*60*60*24); var h = math.floor (t/1000/60/60); t- = h*60*60*1000; var m = math.floor (t/1000/60/60); t- = m*60*1000; var s = math.floor (t/1000);*/var d = math.floor (t/1000/60/60/24); var h = math.floor (t/1000/60/60%24); var m = math.floor (t/1000/60%60); var s = 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, 1,000); </script> </body> </html>