<SCRIPT LANGUAGE="JavaScript"> var timerID; var timerRunning = false; var today = new Date(); var startday = new Date(); var secPerDay = 0; var minPerDay = 0; var hourPerDay = 0; var secsLeft = 0; var secsRound = 0; var secsRemain = 0; var minLeft = 0; var minRound = 0; var minRemain = 0; var timeRemain = 0; function stopclock() { if(timerRunning) clearTimeout(timerID); timerRunning = false; } function startclock() { stopclock(); showtime1(); } function showtime1() { startday = new Date("January 1, 2000 00:00 EDT"); startday.setYear("2000"); today = new Date(); secsPerDay = 1000 ; minPerDay = 60 * 1000 ; hoursPerDay = 60 * 60 * 1000; PerDay = 24 * 60 * 60 * 1000; /* Seconds */ secsLeft = (today.getTime() - startday.getTime()) / minPerDay; secsRound = Math.round(secsLeft); secsRemain = secsLeft - secsRound; secsRemain = (secsRemain < 0) ? secsRemain = 60 - ((secsRound - secsLeft) * 60) : secsRemain = (secsLeft - secsRound) * 60; secsRemain = Math.round(secsRemain); /* Minutes */ minLeft = ((today.getTime() - startday.getTime()) / hoursPerDay); minRound = Math.round(minLeft); minRemain = minLeft - minRound; minRemain = (minRemain < 0) ? minRemain = 60 - ((minRound - minLeft) * 60) : minRemain = ((minLeft - minRound) * 60); minRemain = Math.round(minRemain - 0.495); /* Hours */ hoursLeft = ((today.getTime() - startday.getTime()) / PerDay); hoursRound = Math.round(hoursLeft); hoursRemain = hoursLeft - hoursRound; hoursRemain = (hoursRemain < 0) ? hoursRemain = 24 - ((hoursRound - hoursLeft) * 24) : hoursRemain = ((hoursLeft - hoursRound) * 24); hoursRemain = Math.round(hoursRemain - 0.5); /* Days */ daysLeft = ((today.getTime() - startday.getTime()) / PerDay); daysLeft = (daysLeft - 0.5); daysRound = Math.round(daysLeft); daysRemain = daysRound; /* Time */ if (daysRemain == 1) { day_rem = " 天, " } else { day_rem = " 天, " } if (hoursRemain == 1) { hour_rem = " 小时, " } else { hour_rem = " 小时, " } if (minRemain == 1) { min_rem = " 分, " } else { min_rem = " 分, " } if (secsRemain == 1) { sec_rem = " 秒" } else { sec_rem = " 秒" } timeRemain = daysRemain + day_rem + hoursRemain + hour_rem + minRemain + min_rem + secsRemain + sec_rem; document.up.face.value = timeRemain; timerID = setTimeout("showtime1()",1000); timerRunning = true; } </SCRIPT> <body onLoad="startclock()"> <FONT SIZE=+1 FACE="Arial"> <FORM NAME="up"> 2000年至今有<INPUT TYPE="text" style="border:1px solid #FF9900; text-align:center; color:#CC0000" NAME="face" SIZE="30" VALUE="A browser supporting JavaScript 1.1+ is needed.">了 </FORM> </FONT> </body>
评论已关闭!