<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>动态时间显示 </title>
<script language="JavaScript">
<!--
timeID="";
timeRunning=false;
function stop(){
if(timeRunning){
clearTimeout(timeID);
timeRunning=false;
}
}
function time(){
tick=new Date();
hours=tick.getHours();
minutes=tick.getMinutes();
seconds=tick.getSeconds();
current=""+(hours>12)?hours-12:hours;
current+=((minutes <10)?":0":":"+seconds); //这里少括号
current+=(hours>=12)?"P.M":" A.M.";
window.status=current;
timeID=setTimeout("time()",1000);
timeRunning=true;
}
function run(){
stop();
time();
}
//-->
</script>
</head>
<body onload="run()">
</body>
</html>
逻辑好像有点问题啊
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<title>动态时间显示 </title>
<script language="JavaScript">
<!--
timeID="";
timeRunning=false;
function stop(){
if(timeRunning){
clearTimeout(timeID);
timeRunning=false;
}
}
function time(){
tick=new Date();
hours=tick.getHours();
minutes=tick.getMinutes();
seconds=tick.getSeconds();
current=""+((hours>12)?hours-12:hours);
current+=((minutes <10)?":0":":")+minutes; //这里少括号
current+=((seconds <10)?":0":":")+seconds;
current+=(hours>=12)?"P.M":" A.M.";
window.status=current;
timeID=setTimeout("time()",1000);
timeRunning=true;
}
function run(){
stop();
time();
}
//-->
</script>
</head>
<body onload="run()">
</body>
</html>
这行多了个'(',用firebug一下就出来了。