document.info.firstPicture.value为空或不是对象

hengyouyao 2009-10-29 06:21:25
调试书本上的一个动态图片网页,效果出不来,总提示: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>   
<input type="button" name="play" value="动态展示图片"
onClick="if(timeOutID==null){loadModifyPicture();playPicture()}">
   
<input type="button" name="play" value="停止展示图片" onClick="checkPlay();">
</form>
</body>
</html>
图片和原文件放在一起的,没有问题。
...全文
43 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hengyouyao 2009-10-29
  • 打赏
  • 举报
回复
多谢,调试通过。
sohighthesky 2009-10-29
  • 打赏
  • 举报
回复
有好几个都要改
sohighthesky 2009-10-29
  • 打赏
  • 举报
回复
所的<input type="text" name="firstPicture" size=30>

size后面的“"”提前

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧