复制代码 代码如下:
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);
}