下面代码哪里错了?
<html>
<head>
<title>
setTimeout()方法</title>
<script language="javascript">
function TimeDemo(){
var d, s = "当前本地时间为: ";
var c = ":";
d = new Date();
s += d.getHours() + c;
s += d.getMinutes() + c;
s += d.getSeconds();
var mytime=setTimeout("TimeDemo()",1000);
document.write(s);
}
</script></head>
<body onLoad="TimeDemo()"></body>
</html>
<html>
<head>
<title>
setTimeout()方法</title>
<script language="javascript">
function TimeDemo(){
var d, s = "当前本地时间为: ";
var c = ":";
d = new Date();
s += d.getHours() + c;
s += d.getMinutes() + c;
s += d.getSeconds();
var mytime=setTimeout("TimeDemo()",1000);
document.write(s);
}
</script></head>
<body onLoad="TimeDemo()"></body>
</html>
<head>
<title>
setTimeout()方法 </title>
<script language="javascript">
var tid;
function TimeDemo(){
clearTimeout(tid);
var d;
var c = ":";
d = new Date();
var h = d.getHours();
var n = d.getMinutes();
var s = d.getSeconds();
h = h<10?'0'+h:h;
n = n<10?'0'+n:n;
s = s<10?'0'+s:s;
document.getElementById("pad").innerHTML = h + c + n + c + s;
tid =setTimeout("TimeDemo()",1000);
}
</script> </head>
<body onLoad="TimeDemo()">
当前本地时间为: <span id="pad"></span>
</body>
</html>