海尧影视传媒旗下艺人:JavaScript代码错误在哪里?

来源:百度文库 编辑:中科新闻网 时间:2024/05/02 18:55:46
<html>
<head>
<title>图象时钟</title>
</head>

<script language="JavaScript">
function showImg( )
{
myTime=new Date( );
var imageArray=new Array(10);
for(i=0;i<10;i++)
imageArray[i]=new Image( );
imageArray[0].src="0.gif";
imageArray[1].src="1.gif";
imageArray[2].src="2.gif";
imageArray[3].src="3.gif";
imageArray[4].src="4.gif";
imageArray[5].src="5.gif";
imageArray[6].src="6.gif";
imageArray[7].src="7.gif";
imageArray[8].src="8.gif";
imageArray[9].src="9.gif";
year=myTime.getYear( );
month=myTime.getMonth( )+1;
date=myTime.getDate( );
hours=myTime.getHours( );
minutes=myTime.geiMinutes( );
seconds=myTime.geySeconds( );
if(year<100)
year="19"+year;
if(month<10)
month="0"+month;
if(date<10)
date="0"+date;
if(hours<=9)
hours="0"+hours;
if(minutes<=9)
minutes="0"+minutes;
if(seconds<=9)
seconds="0"+seconds;
theString=""+year+month+date+hours+minutes+seconds;
IMG0.src=imageArray[theString.charAt(0)].src;
IMG1.src=imageArray[theString.charAt(1)].src;
IMG2.src=imageArray[theString.charAt(2)].src;
IMG3.src=imageArray[theString.charAt(3)].src;
IMG4.src=imageArray[theString.charAt(4)].src;
IMG5.src=imageArray[theString.charAt(5)].src;
IMG6.src=imageArray[theString.charAt(6)].src;
IMG7.src=imageArray[theString.charAt(7)].src;
IMG8.src=imageArray[theString.charAt(8)].src;
IMG9.src=imageArray[theString.charAt(9)].src;
setTimeout("showImg( )",1000);
}
</script>

<body onload="showImg( )" leftmargin="35px" topmargin="20">
<img id=IMG0><img id=IMG1><img id=IMG2><img id=IMG3>年
<img id=IMG4><img id=IMG5>月<img id=IMG6><img id=IMG7>日
<img id=IMG8><img id=IMG9><img id=IMG10><img id=IMG11>
<img id=IMG12><img id=IMG13>
</body>
</html>

那些该显示时间数字的地方,怎么也显示不出来,帮我看看哪里错了!

0.gif~9.gif这些图片呢?你要把这些图片放在这个文件相同的目录里
还有你代码有问题

minutes=myTime.getMinutes( );
seconds=myTime.getSeconds( ); 这里你写错的

minutes=myTime.geiMinutes( ); 中的minutes是JS里的关键字,你却用来做变量名,所以错了。

回答完毕