日期:2014-05-18  浏览次数:20722 次

JAVASCRIPT问题高手来帮助一下下
<!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 "   />  
<title> Image对象应用 </title>  
<script   type= "text/javascript ">  
<!--  
var   myImage   =   new   Array(9);  
for(var   i=0;i <9;i++)  
{  
myImage[i]   =   new   Image();  
}  
myImage[0].src   =   "PIC/1.jpg ";  
myImage[1].src   =   "PIC/2.jpg ";  
myImage[2].src   =   "PIC/3.jpg ";  
myImage[3].src   =   "PIC/4.jpg ";  
myImage[4].src   =   "PIC/5.jpg ";  
myImage[5].src   =   "PIC/6.jpg ";  
myImage[6].src   =   "PIC/7.jpg ";  
myImage[7].src   =   "PIC/8.jpg ";  
myImage[8].src   =   "PIC/9.jpg ";  
myImage[9].src   =   "PIC/10.jpg ";  
var   k   =   0;  
function   changPIC()  
{  
document.mi1.src   =   myImage[k].src;  
k++;  
if(k   ==   9)  
{  
k   =   0;  
}  
setTimeout(k,2000);  
}  
//-->  
</script>  
</head>  

<body>  
<img   name= "mi1 "   src= "PIC/1.jpg "   />  
<script   type= "text/javascript ">  
<!--  
changPIC();  
//-->  
</script>  
</body>  
</html>  


上面changPIC函数有一个全局变量K.我用alert()在函数中弹出他是一个   undefind  

这个是我在看一本书上的例子.谢谢大侠们指点

------解决方案--------------------
一个明显的错误,数组一共9个元素,怎么还有myImage[9].src = "PIC/10.jpg ";
这不出错吗?