Count-Down Timer
still have been
Sec
until the 2000 year
BODYエレメント開始タグ
<BODY onLoad="Count()">
カウントダウン表示部分
<SPAN id="countDown"></SPAN> Sec <!-- カウントダウンを表示する部分 -->
スクリプト部分
function Count()
{
var date = new Date(); //Dateオブジェクト
var now = date.getTime(); //現在までのミリ秒数
var mil = Date.parse("January 1, 2000 00:00:00");
//2000/01/01 00:00:00までのミリ秒数
var count = (mil - now) / 1000; //ミリ秒の差を1000で割る
count = Math.floor(count); //count以下の最も近い整数に丸める
countDown.innerHTML = count; //IDがcountDownのタグ要素を置きかえる
timerID = setTimeout('Count()', 1000); //1000ms間隔で再帰的に自分を呼び出す
}