TOP /このページのJavaScript カウントダウン



指定した日にちまでをカウントダウンします。
今回は、クリスマスまでのカウントダウンとクリスマスを過ぎてから
正月までのカウントダウンです。
<script type="text/javascript"><!---
today  = new Date ();
Christmas = new Date ("2004/12/25");
NewYear = new Date ("2005/1/1");
Christmas = (Christmas.getTime () - today.getTime ()) / (24*60*60*1000);
NewYear = (NewYear.getTime () - today.getTime ()) / (24*60*60*1000)

if (Math.ceil (Christmas) > "1") {
counttext="クリスマスまであと" + Math.ceil (Christmas) + "日";
}else if (Math.ceil (Christmas) == "1") {
counttext="今日はクリスマス・イブ!";
}else if (Math.ceil (Christmas) == "0") {
counttext="今日はクリスマス!";
}else if (Math.ceil (Christmas) < "0" && Math.ceil (NewYear) > "0") {
counttext="今年もあと" + Math.ceil (NewYear) + "日";
}else {
counttext="明けましておめでとうございます!";
}
document.write(counttext);
window.status =counttext;
//---></script>