<script language="JavaScript">
function GetRTime(){
var mon=parseInt(txtmon.value)-1;
var EndTime= new Date(txtyear.value,mon,txtday.value,txthour.value,txtmin.value); //那一天,那一刻
var NowTime = new Date();
var nMS =EndTime.getTime() - NowTime.getTime();//距离那一天还有这些毫秒
var sec=parseInt(nMS/100)/10;//-31*3600*24*10)/10;//31天的误差,返回的月份是0到11?
if(sec==parseInt(sec))
sec+=".0";
document.getElementById("RemainS").innerHTML=sec;
setTimeout("GetRTime()",100);//0.1秒闪一次
if(sec>0)
{
document.getElementById('CountMsg').innerHTML="您还能活<font color=red>"+document.getElementById('Remains').innerHTML+"</font>秒!";
}
else
{
document.getElementById('Remains').innerHTML=document.getElementById('Remains').innerHTML.substr(1,document.getElementById('Remains').innerHTML.length-1);//去掉负号
document.getElementById('CountMsg').innerHTML="您已经活了<font color=red>"+document.getElementById('Remains').innerHTML+"</font>秒!";
}
}
//window.οnlοad=GetRTime;
</script>
<body>
<br>
<input type=text id=txtyear style="width:80px">年 <input type=text id=txtmon style="width:40px">月 <input type=text id=txtday style="width:40px">
日 <input type=text id=txthour value=0 style="width:40px">时 <input type=text id=txtmin value=0 style="width:40px">分
<br>
<input type=button value="OK" οnclick="GetRTime()" style="width:60px">
<br><br><h1><b><div id="CountMsg" width=100% align=center ></div></b><h1>
<span id=RemainS style="color=red;display:none"></span>
</body>