调试书本上的一个动态图片网页,效果出不来,总提示:document.info.firstPicture.value为空或不是对象,望各位大侠帮帮忙,不胜感激,下面是代码(帮帮看下哪有错啊 )
 <html>
<head>
<title>image对象的使用</title>
<script language="javaScript">
var number=0;
var timeOutID=null;
var picture =new Array(3);
for(var i=0;i<3;i++)
{
picture[i]=new Image();
}function checkValid(s)
{
var len=s.length;
for(var i=0;i<len;i++)
{
if(s.charAt(i)!=" ")
{
return true;
}
}
return false;
}function loadNewPicture()
{
picture[0].url="1.JPG";
picture[1].url="2.JPG";
picture[2].url="3.JPG";
}function loadModifyPicture()
{
if(checkValid(document.info.firstPicture.value))
{
picture[0].url=document.info.firstPicture.value;
}
else
{
picture[0].url="1.JPG";
}
if(checkValid(document.info.secondPicture.value))
{
picture[1].url=document.info.secondPicture.value;
}
else
{
picture[1].url="2.jpg";
}
if(checkValid(document.info.thirdPicture.value))
{
picture[2].url=document.info.thirdPicture.value;
}
else
{
picture[2].url="3.jpg";
}
}function setPicture(sort)
{
var pictureURL="";
if(sort=="first")
{
if(checkValid(document.info.firstPicture.value))
{
pictureURL=document.info.firstPicture.value;
}
else
{
pictureURL="1.jpg";
}
}
else if(sort=="second")
{
if(checkValid(document.info.secondPicture.value))
{
pictureURL=document.info.secondPicture.value;
}
else
{
pictureURL="2.jpg";
}
}
else if(sort=="third")
{
if(checkValid(document.info.thirdPicture.value))
{
pictureURL=document.info.thirdPicture.value;
}
else
{
pictureURL="3.jpg";
}
}
document.info.showPicture.src=pictureURL;
}function checkPlay()
{
if(timeOutID!=null)
{
clearTimeout(timeOutID);
timeOutID=null;
}
}function playPicture()
{
document.info.showPicture.src=picture[number].url;
number=(number+1)%3;
timeOutID=setTimeout("playPicture()",1500);
}
</script>
</head>
<body onLoad="loadNewPicture()">
<form name="info">
<h3>image对象的使用</h3>
<img src="1.jpg" name="showPicture" border=10 hspace=15 vspace=15 width=640 heigth=427>
<br>
<font size=2>重新设置第一幅图片:</font>
<input type="text" name="firstPicture size=30">
<input type="button" name="setFirstPicture" value="设置为静态图片"
onclick="checkPlay();setPicture('first')">
<br>
<font size=2>重新设置第二幅图片:</font>
<input type="input" name="secondPicture size=30">
<input type="button" name="setsecondPicture" value="设置为静态图片"
onclick="checkPlay();setPicture('second')">
<br>
<font size=2>重新设置第三幅图片:</font>
<input type="input" name="thirdPicture size=30">
<input type="button" name="setthirdPicture" value="设置为静态图片"
onclick="checkPlay();setPicture('third')">
<br><br>&nbsp;&nbsp;&nbsp;
<input type="button" name="play" value="动态展示图片"
onClick="if(timeOutID==null){loadModifyPicture();playPicture()}">
&nbsp;&nbsp;&nbsp;
<input type="button" name="play" value="停止展示图片" onClick="checkPlay();">
</form>
</body>
</html>
图片和原文件放在一起的,没有问题。