//参考w3c资料自己编写
网页定时器(时钟的编写)
结果图:
[img]http://dl2.iteye.com/upload/attachment/0090/8300/d79a4809-81fd-3b7e-be0d-54783639ce44.png[/img]
网页定时器(时钟的编写)
<html>
<head>
<title>28</title>
<script type="text/javascript">
function startTime(){
var today= new Date();
var y=today.getFullYear();
var mon=today.getMonth()+1;
var d=today.getDate();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
mon=checkTime(mon);
d=checkTime(d);
m=checkTime(m);
s=checkTime(s);
document.getElementById("007").innerHTML=""+y+"年"+mon+"月"+d+"日"+" "+h+":"+m+":"+s;
t=setTimeout('startTime()',1000);
}
function checkTime(i){
if(i<10)
{i="0"+i;}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="007" style="background:green;"></div>
</body>
</html>
结果图:
[img]http://dl2.iteye.com/upload/attachment/0090/8300/d79a4809-81fd-3b7e-be0d-54783639ce44.png[/img]