节日倒计时
<Script Language="JavaScript">
var timedate= new Date("October 1,2003");
var times="国庆节";
var now = new Date();
var date = timedate.getTime() - now.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24));
if (time>=0)
document.write("现在离"+times+"还有:"+time +"天")</Script>
<Script Language="JavaScript">
var timedate= new Date("October 1,2003");
var times="国庆节";
var now = new Date();
var date = timedate.getTime() - now.getTime();
var time = Math.floor(date / (1000 * 60 * 60 * 24));
if (time>=0)
document.write("现在离"+times+"还有:"+time +"天")</Script>
{//倒计时函数
var today,days,hours,minutes,seconds,inHours,inMinutes,inSeconds;
today=new Date();//当前时间
days=Math.floor((someDay.getTime()-today.getTime())/(1000*60*60*24));//计算剩余天数
inHours = today.getHours();
hours = (12>inHours)?(23-inHours):(eval(23-inHours));
minutes = 60 - today.getMinutes();
seconds = 60 - today.getSeconds();
//inSeconds = today.getHours();
//seconds = (50>inSeconds); /*以上分别计算剩余时间的小时、分钟、秒*/
//inSeconds = today.getHours();
//seconds = (50>inSeconds); /*以上分别计算剩余时间的小时、分钟、秒*/
/*if(days>0)
{
timeString='离2002年考研还有'+eval(days+1)+'天!';
timeString='离考研还有'+hours+'个小时'+minutes+'分钟'+seconds+'秒';
}
else if(days==0)
{
if(hours=='00'&&minutes=='00'&&seconds=='00') timeString=false;
else timeString='离考研还有'+hours+'个小时'+minutes+'分钟'+seconds+'秒';
}
else timeString='祝你成功!';
*/
timeString='离考研还有'+eval(days+1)+'天'+hours+'个小时'+minutes+'分钟'+seconds+'秒';
if(!timeString) windows.alert('开考了');
cutdownDiv.innerHTML=timeString;//输出
downing=window.setTimeout('cutdown()',100);
}window.onload=cutdown;//网页载入完成开始倒计时//--></script><div id="cutdownDiv"></div>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD><BODY onload="on_load()">
<INPUT NAME="txt_time" width="100" style="FONT-WEIGHT: bold; WIDTH: 170px; COLOR: #ff0000; HEIGHT: 22px; BACKGROUND-COLOR: black; TEXT-ALIGN: center" readonly>
</BODY>
</HTML>
<SCRIPT LANGUAGE="JavaScript">
<!--
var in_time;
var flg = 0;
var now = new Date;
in_time = now.getTime();
function on_load() {
var st_time = "";
var st_year = now.getFullYear();
var st_month = now.getMonth()+1<10?"0"+eval(now.getMonth()+1):now.getMonth()+1;
var st_day = now.getDate()<10?"0"+now.getDate():now.getDate();
var st_hour = now.getHours()<10?"0"+now.getHours():now.getHours();
var st_min = now.getMinutes()<10?"0"+now.getMinutes():now.getMinutes();
var st_sec = now.getSeconds()<10?"0"+now.getSeconds():now.getSeconds(); st_time = st_time + st_year;
st_time = st_time + "-" + st_month;
st_time = st_time + "-" + st_day;
st_time = st_time + " " + st_hour;
st_time = st_time + ":" + st_min;
st_time = st_time + ":" + st_sec;
txt_time.value = st_time;
in_time -= 1000;
now.setTime( in_time );
chk_flg();
if( flg == 0 ) {
window.setTimeout(on_load,1000);
}
}
function chk_flg() {
var date_chk = new Date;
// 倒计时到2003-11-10 00:00:00
date_chk.setFullYear(2003,10,10); // note : month - 1
date_chk.setHours(0,0,0,0);
if( in_time <= date_chk.getTime() ) {
flg = 1;
alert("2003-11-10 00:00:00");
}
}
//-->
</SCRIPT>