<html>
<head>
<title>clock</title>
<script language="javascript">
var timerID = null; //Here
var timerRunning = false;
function stopClock() {
if (timerRunning)
{
clearTimerout(timerID);
timerRunning = false;
document.clock.face.value = "";
}
}
function showTimer(){
//timerID =setTimeout("showTimer()",1000); //Here
var now =new Date();
var year= now.getYear();
var month = now.getMonth() + 1 ;
var date = now.getDate();
var hours = now.getHours();
var mins = now.getMinutes();
var secs = now.getSeconds();
var timerVar = "";
timerVar += year +"年"
timerVar +=((month <10)?"0" + month : month) + "月";
timerVar += date + "日"
timerVar += ((hours<12) ? hours:hours - 12) + "点";
timerVar +=((mins < 10)?":0":":") + mins + "分";
timerVar +=((secs < 10)?":0":":") + secs + "秒";
document.clock.face.value = timerVar;
window.status= clock.face.value;
timerID = setTimeout("showTimer()",1000);//Here
timerRunning = true;
}
function startClock(){
showTimer();
}
</script>
</head>
<body onLoad="startClock()">
<p align="center"><big><span style="background-color:rgb(45,45,45)">
<font face="宋体">时钟</font>
</span></big></p>
<table border="0" cellspacing="0" cellpadding="0">
<tr><td width="100%">
<form NAME="clock">
<input Type="rext" NAME="face" size="30" style="background-color:rgb(100,100,60)">
</form>
</td>
</tr>
</table>
</body>
</html>
<head>
<title>clock</title>
<script language="javascript">
var timerID = null; //Here
var timerRunning = false;
function stopClock() {
if (timerRunning)
{
clearTimerout(timerID);
timerRunning = false;
document.clock.face.value = "";
}
}
function showTimer(){
//timerID =setTimeout("showTimer()",1000); //Here
var now =new Date();
var year= now.getYear();
var month = now.getMonth() + 1 ;
var date = now.getDate();
var hours = now.getHours();
var mins = now.getMinutes();
var secs = now.getSeconds();
var timerVar = "";
timerVar += year +"年"
timerVar +=((month <10)?"0" + month : month) + "月";
timerVar += date + "日"
timerVar += ((hours<12) ? hours:hours - 12) + "点";
timerVar +=((mins < 10)?":0":":") + mins + "分";
timerVar +=((secs < 10)?":0":":") + secs + "秒";
document.clock.face.value = timerVar;
window.status= clock.face.value;
timerID = setTimeout("showTimer()",1000);//Here
timerRunning = true;
}
function startClock(){
showTimer();
}
</script>
</head>
<body onLoad="startClock()">
<p align="center"><big><span style="background-color:rgb(45,45,45)">
<font face="宋体">时钟</font>
</span></big></p>
<table border="0" cellspacing="0" cellpadding="0">
<tr><td width="100%">
<form NAME="clock">
<input Type="rext" NAME="face" size="30" style="background-color:rgb(100,100,60)">
</form>
</td>
</tr>
</table>
</body>
</html>
timerID = setTimeout("showTime()",1000);
应为
timerID = setTimeout("showTimer()",1000);
其实这一行去掉就可以
与第16行是重的
他已在修改的那一行加了注释!
timerID = setTimeout("showTimer()",1000);//Here"showTime()"
----->>>>>
"showTimer()"