javascrtpt动态显示时间

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:51:34
<html>
<body onload="Time()">
<script language="javascript">
<!--
function Time()
{
todayDate = new Date();
date= todayDate.getDate();
month= todayDate.getMonth()+1;
year= todayDate.getYear();
document.write("今天是"+year+"年"+month+"月"+date+"号");
document.write("<br>");

hour=todayDate.getHours();
minute=todayDate.getMinutes();
second=todayDate.getSeconds();
document.write(hour+":");
document.write(minute<10?"0"+minute:minute);
document.write(":");
document.write(second<10?"0"+second:second);
}
setTimeout("Time()",1000)

//-->
</script>
</body>
</html>

为什么这样还是不能动态显示时间呢,还是什么都没变化?
我是新手,请帮我看看哪里错了
请问一下第一位:
DT.innerHTML=theTime;
setTimeout("showTime()

好像不能用document.write

换<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>数字时钟</title>
</head>
<script language="JavaScript">
<!--
function showTime()
{
myTime=new Date();
var monthArray=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
var dayArray =new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");
year=myTime.getYear();
date=myTime.getDate();
hours=myTime.getHours();
minutes=myTime.getMinutes();
seconds=myTime.getSeconds();
suf="AM";
if(hours>12)
{
suf="PM";
hours=hours-12;
}
if(hours==0)
hours=12;