loop through an array and load image

J

Jeepers321

Here is some idea of what I am trying to do.

1 - Preload my images to the page.
2 - When user clicks the imgclick.gif
2 - the javascript will loop through these images one at a time at
approximatly 50 millisconds using id="imgmain" as its holder.
3 - when the javascript gets to the the last image in the loop I need
to have another webpage load with the target being _self.

Here is the javascript that I have so far.

<html>

<head>
<title></title>

<script language="javascript"><!--
//Preload Images
var image01 = new Image();
image01.src = "images/img1.gif";
var image02 = new Image();
image02.src = "images/img2.gif";
var image03 = new Image();
image03.src = "images/img3.gif";

function doPreload()
{
var the_images = new Array('images/img1.gif',
'images/img2.gif',
'images/img3.gif');
preloadImages(the_images);
}
function preloadImages(the_images_array) {
for(var loop = 0; loop < the_images_array.length;
loop++)
{
var an_image = new Image();
an_image.src = the_images_array[loop];
}
}

// Not sure how to build a function here that will loop through the
images(or the Array) and and load the images into the "imgmain".


//--></script>

<meta content="Microsoft Visual Studio .NET 7.1"
name="GENERATOR">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</head>

<body onload="doPreload();">
<IMG id="imgmain" src="images/img1.gif" border="0">
<IMG id="imgclick" src="images/imgclick.gif">
</body>

</html>


Any help would be greatly appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top