Posts: 40
Name: Bob Davis
Location: Los Angeles, CA
|
When I preload my images via an Array, my automatic slide show doesn't work. My code is below. Any help is appreciated.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>JS - Image Object - Creating a Random Image Slide Show</title>
<script type="text/javascript">
<!--
var imageList = new Array ();
imageList[0] = new Image ();
imageList[0].src = "_external_files/Image1.jpg";
imageList[1] = new Image ();
imageList[1].src = "_external_files/Image2.jpg";
imageList[2] = new Image ();
imageList[2].src = "_external_files/Image3.jpg";
imageList[3] = new Image ();
imageList[3].src = "_external_files/Image4.jpg";
//-->
</script>
</head>
<body>
<img src="_external_files/Image1.jpg" name="slideShow" width="600" height="400" alt="people and things" />
<script type="text/javascript">
<!--
function slideShow () {
var imageNumber = (Math.floor(Math.random () * imageList.length)); // determines a random image number
document.images.slideShow.src = imageList[imageNumber];
window.setTimeout ("slideShow ();", 3000);
}
window.setTimeout ("slideShow ();", 3000);
slideShow ();
//-->
</script>
</body>
</html>
|