我们这里只要自己定义一下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> document.write("只有2天啦!")<BR>else if (dni == 0)<BR> document.write("只有1天啦!")<BR>else<BR> document.write("好象已经过了哦!");<BR>// --> <BR> 精确到秒的javascript倒计时代码 HTML代码: 复制代码 代码如下: 离2010年还有: <BR>startclock() <BR>var timerID = null; <BR>var timerRunning = false; <BR>function showtime() { <BR>Today = new Date(); <BR>var NowHour = Today.getHours(); <BR>var NowMinute = Today.getMinutes(); <BR>var NowMonth = Today.getMonth(); <BR>var NowDate = Today.getDate(); <BR>var NowYear = Today.getYear(); <BR>var NowSecond = Today.getSeconds(); <BR>if (NowYear <2000) <BR>NowYear=1900+NowYear; <BR>Today = null; <BR>Hourleft = 23 - NowHour <BR>Minuteleft = 59 - NowMinute <BR>Secondleft = 59 - NowSecond <BR>Yearleft = 2009 - NowYear <BR>Monthleft = 12 - NowMonth - 1 <BR>Dateleft = 31 - NowDate <BR>if (Secondleft<0) <BR>{ <BR>Secondleft=60+Secondleft; <BR>Minuteleft=Minuteleft-1; <BR>} <BR>if (Minuteleft<0) <BR>{ <BR>Minuteleft=60+Minuteleft; <BR>Hourleft=Hourleft-1; <BR>} <BR>if (Hourleft<0) <BR>{ <BR>Hourleft=24+Hourleft; <BR>Dateleft=Dateleft-1; <BR>} <BR>if (Dateleft<0) <BR>{ <BR>Dateleft=31+Dateleft; <BR>Monthleft=Monthleft-1; <BR>} <BR>if (Monthleft<0) <BR>{ <BR>Monthleft=12+Monthleft; <BR>Yearleft=Yearleft-1; <BR>} <BR>Temp=Yearleft+'年, '+Monthleft+'月, '+Dateleft+'天, '+Hourleft+'小时, '+Minuteleft+'分, '+Secondleft+'秒' <BR>document.form1.left.value=Temp; <BR>timerID = setTimeout("showtime()",1000); <BR>timerRunning = true; <BR>} <BR>var timerID = null; <BR>var timerRunning = false; <BR>function stopclock () { <BR>if(timerRunning) <BR>clearTimeout(timerID); <BR>timerRunning = false; <BR>} <BR>function startclock () { <BR>stopclock(); <BR>showtime(); <BR>} <BR>// --> <BR>