可用javascript 做一个定时器
<script language="JavaScript">
var staDate = 300;//单位:秒.1天=86400秒,1小时=3600秒
var startTime = (new Date()).getTime();
var Temp;
var timerID = null;
var timerRunning = false;
function time1(){
now = new Date();
var ts=parseInt((startTime-now.getTime())/1000)+staDate;
var shengdate = 0;
var shenghour = 0;
var shengminu = 0;
var shengsecon = 0;
if(ts < 0){
ts = 0;
CurHour = 0;
CurMinute = 0;
CurSecond = 0;}
else
{
shengdate =parseInt(ts/86400);//剩余天数
ts = ts - shengdate * 86400;
shenghour = parseInt(ts/3600);
ts = ts - shenghour * 3600;
shengminu = parseInt(ts/60);
shengsecon = ts - shengminu * 60;}
if(shenghour < 10) shenghour = '0' +shenghour;
if(shengminu < 10) shengminu = '0' +shengminu;
if(shengsecon<10) shengsecon='0'+shengsecon;
if( shengdate > 0 )
shengdate = shengdate + "天"
;
else
shengdate = "";
if( shenghour > 0 )
shenghour = shenghour + "小时"
;
else
{
if( shengdate != ""
)
shenghour = "00小时";
else
shenghour = "";}
if( shengminu > 0 )
shengminu = shengminu + "分钟"
;
else
{
if( shengdate !=""
|| shenghour != ""
shengminu = "00分钟";
else
shengminu = "";}
if( shengsecon > 0 )
shengsecon = shengsecon + "秒"
;
else
{
if( shengdate !=""
|| shenghour != ""
|| shengminu != ""
shengsecon = "00秒";
else
shengsecon = "";}
//if (shengdate == '') {
Temp=shengdate+shenghour+shengminu+shengsecon ;
//}else
{
//Temp=shengdate+shenghour;}
if(shengdate <=0 &&
shenghour<=0 &&
shengminu<=0 &&
shengsecon <=0)
{
Temp = "结束";
document.getElementById('time').value=Temp;
stopclock();
alert("时间已经到了!"
;
location.href="index.aspx";
}
if (document.getElementById('time'))do
cument.getElementById('time').value=Temp;
timerID = setTimeout("time1()",1000);
timerRunning = true;}
var timerID = null;
var timerRunning = false;
function stopclock()
{
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function tingclock(){
stopclock();
time1();}
function onloadall(){
tingclock();
try{
chushi();
}
catch(e){
}}
try{
onload=onloadall();}
catch(e){}
</script>