Web Analytics Made Easy -
StatCounter Preloading images with JavaScript - CodingForum

Announcement

Collapse
No announcement yet.

Preloading images with JavaScript

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Preloading images with JavaScript

    Hello,
    i would enormously appreciate any help possible on this:

    I have a JS image scroller that bogs down to the point of no return when there are too many thumbnails loaded into it.

    is there a way to preload the images / would that even help ?

    The twist is this: the images are dynamically loaded from a database, so i don't know their hard-coded names.


    i'd be happy to post some code if someone let's me know.

    thanks soooo much

  • #2
    Code:
    var arr = new Array();
    var preload = new Array();
    
    [b]//these must be generated in the server-side
    arr[0] = "image1.jpg";
    arr[1] = "image2.jpg";
    arr[2] = "image3.jpg";
    arr[3] = "image4.jpg";
    //and so on...[/b]
    
    //preload
    for (var i=0;i<arr.length;i++){
      preload[i] = new Image();
      preload[i].src = arr[i];
    }
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      //these must be generated in the server-side
      arr[0] = "image1.jpg";
      arr[1] = "image2.jpg";
      arr[2] = "image3.jpg";
      arr[3] = "image4.jpg";
      //and so on...
      why must these be generated in the server-side?
      http://www.bluephoenix.uni.cc/

      Comment


      • #4
        Originally posted by codenode
        The twist is this: the images are dynamically loaded from a database, so i don't know their hard-coded names.
        Glenn
        vBulletin Mods That Rock!

        Comment

        Working...
        X