首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

求高手给小弟我看一下代码哪里出错了

2012-03-17 
求高手给我看一下代码哪里出错了!DOCTYPEhtmlPUBLIC-//W3C//DTDXHTML1.0Transitional//EN http://www.

求高手给我看一下代码哪里出错了
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<style   type= "text/css "> </style>
<title> 无标题文档 </title>
<script   language= "javascript ">
function   showClock()   {
}
function   hideClock()   {
}
var   timerID   =   null
var   timerRunning   =   false

function   stopClock()   {
if(timerRunning)
clearTimeout(timerID);
timerRunning   =   false
document.clock.face.value   =   " ";
}
function   showTime()   {
var   now   =   new   Date();
var   year   =   getYear();
var   month   =   now.getMonth()   +1;
var   date   =   now.getDate();
var   hours   =   now.getHours();
var   mins   =   now.getMinutes();
var   secs   =   now.getSeconds();
var   timeVal   =   " ";
timeVal   +=   ((hours   <=   12)   ?   hours   :   hours   -   12);
timeVal   +=   ((mins   <   10)   ?   ":0 "   :   ": ")   +   mins;
timeVal   +=   ((hours   <   12)   ?   "AM "   :   "PM ");
timeVal   +=   ((month   <   10)   ?   "on   0 "   :   "on ")   +   month   +   "- ";
timeVal   +=   date   +   "- "   +   year;
document.clock.face.value   =   timeVal;
timerID   =   setTimeout( "showTime() ",1000);
timerRunning   =   true
}
function   startClock()   {
stopClock();
showTime();
}
function   windowOpener(   indexnum   ){
var   loadpos   =   "date.html "   +   "# "   +indexnum;
controlWindow   =   window.open(loadpos, "date ", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=400 ");
}
</script>
</head>
<body   onload= "startClock() ">
<p   align= "center ">
<big>
<span   style= "background-color:   rgb(45,45,45) "> <font   face= "Arial "> form </font>
<font   face= "宋体 "> 时钟 </font>
</span>
</big>
</p>
<div   align= "center "> <center>
<table   border= "0 "   cellspacing= "0 "   cellpadding= "0 ">
<tr>
<td   width= "100% ">
<form   name= "clock "   onsubmit= "0 ">
<div   align= "center ">
<center> <p> <input   type= "text "   name= "face "   size= "20 "   value   style= "background-color:   rgb(192,192,192) "   />
</p> </center> </div> </form> </td> </tr> </table> </center> </div>


</body>
</html>


运行总会出错,哪位大侠在百忙中帮忙解决一下,谢谢

[解决办法]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<style type= "text/css "> </style>
<title> 无标题文档 </title>
<script language= "javascript ">
function showClock() {
}
function hideClock() {
}
var timerID = null
var timerRunning = false

function stopClock() {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false
document.clock.face.value = " ";
}
function showTime() {
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 timeVal = " ";
timeVal += ((hours <= 12) ? hours : hours - 12);
timeVal += ((mins < 10) ? ":0 " : ": ") + mins;
timeVal += ((hours < 12) ? "AM " : "PM ");
timeVal += ((month < 10) ? "on 0 " : "on ") + month + "- ";
timeVal += date + "- " + year;
document.clock.face.value = timeVal;
timerID = setTimeout( "showTime() ",1000);
timerRunning = true
}
function startClock() {
stopClock();
showTime();
}
function windowOpener( indexnum ){
var loadpos = "date.html " + "# " +indexnum;
controlWindow = window.open(loadpos, "date ", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=400 ");
}
</script>
</head>
<body onload= "startClock() ">
<p align= "center ">
<big>
<span style= "background-color: rgb(45,45,45) "> <font face= "Arial "> form </font>
<font face= "宋体 "> 时钟 </font>
</span>
</big>
</p>
<div align= "center "> <center>
<table border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td width= "100% ">
<form name= "clock " onsubmit= "0 ">
<div align= "center ">
<center> <p> <input type= "text " name= "face " size= "20 " value style= "background-color: rgb(192,192,192) " />
</p> </center> </div> </form> </td> </tr> </table> </center> </div>
</body>
</html>

热点排行