求解,为什么这个函数的参数要这样写?
这是个图片自动播放程序<html>
<head>
<title>A Timed Slide Show</title>
<script type = "text/javascript">
<!-- hide me from older browsers
var the_images = new Array();
the_images[0] = new Image();
the_images[0].src = "one.jpg";
the_images[1] = new Image();
the_images[1].src = "two.jpg";
the_images[2] = new Image();
the_images[2].src = "three.jpg";
var the_timeout;
function rotateImage(index)
{
window.document.my_image.src = the_images[index].src;
index++;
if (index >= the_images.length)
{
index = 0;
}
the_timeout = setTimeout("rotateImage("+index+");", 1000);
}
// show me -->
</script>
</head>
<body>
<img name = "my_image" src="one.jpg">
<form>
<input type = "button" value = "Start the Show" onClick = "rotateImage(0);">
<input type = "button" value = "Stop the Show" onClick = "clearTimeout(the_timeout);">
</form>
</body>
</html>
在下新手,可能在描述问题的时候有些细节无法讲清,请各位见谅。不明白的地方我用红色标出来了。谁能讲讲为什么要这样写,以及为什么将其替换成index程序会出错呢?