function settime()
{
var myyear,mymonth,myweek,myday,mytime,mymin,myhour,mysec;
var mydate=new Date();
myyear=mydate.getFullYear();
mymonth=mydate.getMonth();
myday=mydate.getDate();
myhour=mydate.getHours();
mymin=mydate.getMinutes();
mysec=mydate.getSeconds();
mytime="今天是:"+myyear+"年"+mymonth+"月"+myday+"日"+myhour+":"+mymin+":"+mysec;
document.getElementById('xwgtime').innerHTML=mytime;
setTimeout('settime()',1000);
}
这样就能显示时间了!脚本真的很强大。。。!用该方法也可以做出网站过几少后自己转换到时另一个页面去的功能!
例如:
function SetTime(NomeTime)
{
document.getElementById("TimeValue").innerHTML=NomeTime+"秒后自动登录";
NomeTime--;
if(NomeTime==-1)
{
document.getElementById("TimeValue").style.display="none";
return;
}
window.setTimeout("javascript:SetTime("+NomeTime+")",1000);
}
其中NomeTime为初始时间大小比如10秒!