loop through an array and load image

Discussion in 'Javascript' started by Jeepers321@yahoo.com, Jul 27, 2006.

  1. Guest

    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.
    , Jul 27, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. uidzer0
    Replies:
    3
    Views:
    1,139
    David Thompson
    Apr 28, 2008
  2. Roedy Green
    Replies:
    3
    Views:
    412
    Mike Schilling
    Sep 13, 2008
  3. Saeed Bhuta
    Replies:
    5
    Views:
    190
    Charles Johnson
    Apr 22, 2010
  4. lawpoop
    Replies:
    17
    Views:
    738
    Thomas 'PointedEars' Lahn
    Jun 22, 2009
  5. Isaac Won
    Replies:
    9
    Views:
    347
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page