A countdown
A countdown can be useful for counting the number of days from now until Christmas.
Add this script to your page between the
<head> and
</head> tags:
<SCRIPT LANGUAGE="JavaScript">
<!--
function getRemaining() {
today = new Date();
targetdate = new Date("December 25, 2001");
targetdate.setYear(today.getYear());
milliseconds = (24 * 60 * 60 * 1000);
remaining = ((targetdate.getTime() - today.getTime()) / milliseconds);
remaining = Math.round(remaining);
}
// -->
</SCRIPT>
The date of your countdown deadline must be specified as follows:
December 25, 2001 (
Month Day, Year).
Then place the following code where you want your countdown to appear:
<SCRIPT LANGUAGE="JavaScript">
<!--
getRemaining();
document.write("There are ",remaining," days left before Christmas!");
// -->
</SCRIPT>
Discover all Webmaster scripts.