代码:
-
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<div id="time_bar"></div>
<script type="text/javascript">
var od = function(){};
od.prototype.oc = new Array('日','一','二','三','四','五','六');
od.prototype.w = function (b){
return this.oc[b];
}
od.prototype.h = function(t){
if(t<10)return '0'+t;
return t;
}
var d = new od();
var r = function run (){
var now =new Date().getFullYear()+'年' +
(new Date().getMonth()+1)+'月' +
new Date().getDate()+'日'+' ' +
'星期'+d.w(new Date().getDay())+' '+
d.h(new Date().getHours())+':'+
d.h(new Date().getMinutes())+':'+
d.h(new Date().getSeconds());
document.getElementById("time_bar").innerHTML = now;
}
r();
setInterval(r,1000) ;
</script>
</body>
</html>
-
本文介绍了一个简单的HTML页面,该页面使用JavaScript每隔一秒更新并显示当前的日期和时间,包括年、月、日、星期几以及具体的时间。

被折叠的 条评论
为什么被折叠?



