我們這裡只要自己定義一下s與urodz的值就可以隨意定義任何日期或節日的倒數計時功能了,各位朋友可加以修改。 精確到天的倒數計時 複製程式碼複製程式碼 程式碼🎜><BR><!-- // (c) Henryk Gajewski<BR>var urodz= new Date("09/19/2013");<BR>var s="中秋節";<BR>var now = new Date();<BR>var ile = urodz.getTime() - now.getTime();<BR>var dni = Math.floor(ile / (1000 * 60 * 60 * 24));<BR>if (dni > 1)<BR> document.write("" s "還有" dni "天")<BR>else if (dni == 1)<BR> rite document. ("只有2天啦!")<BR>else if (dni == 0)<BR> document.write("只有1天啦!")<BR>else<BR> document.write("好像已經過了哦! <BR> 精確到秒的javascript倒計時代碼 HTML代碼: 複製代碼 代碼如下: 離2010年還有: 離2010年還有: <BR>startclock() <BR>var timerID = null; <BR>var timerRunning = false; <BR>function showtime(ate ; <BR>var NowHour = Today.getHours(); <BR>var NowMinute = Today.getMinutes(); <BR>var NowMonth = Today.getMonth(); 🎜>var NowYear = Today.getYear(); <BR>var NowSecond = Today.getSeconds(); <BR>if (NowYear <2000) <BR>NowYear=1900 Hourleft = 23 - NowHour <BR>Minuteleft = 59 - NowMinute <BR>Secondleft = 59 - NowSecond <BR>Yearleft = 2009 - NowYear <BR>Yearleft = 2009 - NowYear <comh ate <BR> if (Secondleft<0) <BR>{ <BR>Secondleft=60 Secondleft; <BR>Minuteleft=Minuteleft-1; < 60 Minuteleft; <BR>Hourleft=Hourleft-1; <BR>} <BR>if (Hourleft<0) <BR>{ <BR>Hourleft=24 Hourleft > <BR>if (Dateleft<0) <BR>{ <BR>Dateleft=31 Dateleft; <BR>Monthleft=Monthleft-1; <BR>} left =12 Monthleft; <BR>Yearleft=Yearleft-1; <BR>} <BR>Temp=Yearleft '年, ' Monthleft '月, ' Dateleft '天, ' Hourleft '小時, ' Minuteleft '分 ' ' <BR>document.form1.left.value=Temp; <BR>timerID = setTimeout("showtime()",1000); <BR>timerRunning = true; <BR>); 🎜>var timerRunning = false; <BR>function stopclock () { <BR>if(timerRunning) <BR>clearTimeout(timerID); clock () { <BR>stopclock(); <BR>showtime(); <BR>} <BR>// --> <BR>