春节倒计时


这个脚本在过了阳历年后开作春节来临的倒计时。

拷贝以下代码贴于有关网页的 BODY 范围内您需要展示春节倒计时的部位。

<SCRIPT LANGUAGE="JavaScript"> <!-- Begin var day_description = "春节"; var day_before = "大年三十"; var today = new Date(); var year = today.getYear(); if ((navigator.appName == "Microsoft Internet Explorer") && (year < 2000)) year="19" + year; if (navigator.appName == "Netscape") year=1900 + year; var date = new Date("February 9, " + year); var diff = date.getTime() - today.getTime(); var days = Math.floor(diff / (1000 * 60 * 60 * 24)); document.write("<center><h3>") if (days > 1) document.write("还剩" + (days+1) + "天就到" + day_description + "!"); else if (days == 1) document.write("明天是 " + day_before + "!"); else if (days == 0) document.write("今天是" + day_before + "!"); else if (days == -1) document.write("今天我们过" + day_description + "!"); else if (days < -1) document.write("现在就给" + day_description +"倒计时太早啦!"); document.write("</h3></center>"); // End --> </script>

注意:因每年春节不在同一个阳历日期,所以必须预先查阅来临的春节是在阳历的哪一天,把脚本中的February 9修改过来。

就是如此简单!
请享用