Results 1 to 4 of 4

Thread: pre load images?

  1. #1
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default pre load images?

    Hello, I have some buttons that change image when you hold over them (like hover) but it takes about a second before something happens the first time you hold over them because the image have to load in the browser. I was just wondering if theres anyway you can pre load them without showing them?

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    If they are css rollovers, you can just place the images right after the body tag in an absolutely positioned division that has its visibility set to hidden. If they are javascript rollovers, here is a simple way to preload. Place this script in the head of your page:

    Code:
    <script type="text/javascript">
    (function(){
    //Place all rollover images in the below array:
    var roll_images=['over1.gif','over2.gif', 'over3.gif'];
    ///////////// Stop Editing /////////////
    var p=[];
    for (var i = 0; i < roll_images.length; i++){
    p[i]=new Image();
    p[i].src=roll_images[i];
    };
    })();
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Aug 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, didnt think about using the hidden layer

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •