⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2002年倒计时.txt

📁 JavaScript特效(新)这里有许多的JAVA特效.供学者参考
💻 TXT
字号:
将下列代码复制到<body></body>之间:
<body TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#7F00FF" VLINK="#095FF0" ALINK="#FFFFFF" onLoad="startclock()">
<SCRIPT Language="JavaScript">
<!-- Hiding script from old browsers


var timerID;
var timerRunning = false;
var today = new Date();
var enday = 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;


/* This function will stop the clock */

function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}

/* This function will start the clock */

function startclock () {
stopclock();
showtime();
}

/* 
This is the heart of the script

today is the date today, wow.
enday is the date you want to count til. For this example enday is the year 2002.
secsPerDay will be used to get the seconds per day, double wow.
you should be able to figure out minPerDay, hoursPerDay, and PerDay.
*/


function showtime () {
today = new Date();
enday = new Date("December, 31 2001 23:59");
enday.setYear("2001");
secsPerDay = 1000 ;
minPerDay = 60 * 1000 ;
hoursPerDay = 60 * 60 * 1000;
PerDay = 24 * 60 * 60 * 1000;


/*Seconds*/

/*
secsLeft is the raw seconds remaining until the date.
secsRound is the rounded seconds remaining until the date.
secsRemain is the re-configured seconds. The seconds need to be
limited from 59 to 0 much like a real clock counts. This will do it.
*/


secsLeft = (enday.getTime() - today.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 is the raw minutes remaining until the date.
minRound is the rounded seconds remaining until the date.
minRemain is the re-configured minutes. The minutes need to be
limited from 59 to 0 much like a real clock. Gosh I feel like a
skipping record. Oh well.
*/


minLeft = ((enday.getTime() - today.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 is the raw hours remaining until the date.
hoursRound is the rounded hours remaining until the date.
hoursRemain is the re-configured hours. The hours need to be
limited from 23 to 0 much like a real clock. I think you're starting
to get the picture, no?
*/


hoursLeft = ((enday.getTime() - today.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 is the raw days remaining until the date.
daysRound is the rounded days remaining until the date.
daysRemain is the re-configured days. The days need to be 
rounded, guess daysRound is not needed, but it sure looks 
good don't it?
*/


daysLeft = ((enday.getTime() - today.getTime()) / PerDay);

daysLeft = (daysLeft - 0.5);

daysRound = Math.round(daysLeft);

daysRemain = daysRound;


/*Time*/

/*
timeRemain makes the clock more elegant.
document.clock.face.value is used to show the time remaining.
timeID controls the refresh rate of the clock. The number is the rate in 
milliseconds.
The if statement will stop the clock when the time has expired.
*/


timeRemain = daysRemain + " 天, " + hoursRemain + " 小时, " + minRemain + " 分钟, " + secsRemain + " 秒";

document.clock.face.value = timeRemain;
timerID = setTimeout("showtime()",1000);
timerRunning = true;

if (daysRemain < 0) {

clearTimeout(timerID);
timerRunning = false;
document.clock.face.value = "Time Has Expired";
}

}

// end hiding contents from old browsers  -->
</SCRIPT>

<CENTER><P>
</CENTER>

<FORM name="clock" onSubmit="0">
  <p align="center"><BR>
<BR>
<B><font color="#FF0000" size="5" face="黑体">现在离2002年还有:</font></B>
<CENTER><P> <INPUT type="text" name="face" size=50 value=""></FORM></CENTER>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -