SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Preload Issue

  1. #1
    SitePoint Enthusiast xinete's Avatar
    Join Date
    Jan 2003
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Preload Issue

    Hi, im working on a webpage with rollover buttons, and im noticing that on everylink of the page the page reload the buttons again,and again, is there something i can do to use them from cache instead load them every time? it could save time for audience and bandwith for the hosting :) the rollover was made for imageready

    http://www.dotshirt.com is the link

    the script is

    <SCRIPT TYPE="text/javascript">
    <!--
    function newImage(arg) {
    if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
    }
    }
    function changeImages() {
    if (document.images && (preloadFlag == true)) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
    document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
    }
    }
    }
    var preloadFlag = false;
    function preloadImages() {
    if (document.images) {
    index2new_04_over = newImage("images/index2new_04-over.gif");
    index2new_05_over = newImage("images/index2new_05-over.gif");
    index2new_06_over = newImage("images/index2new_06-over.gif");
    index2new_07_over = newImage("images/index2new_07-over.gif");
    index2new_08_over = newImage("images/index2new_08-over.gif");
    index2new_09_over = newImage("images/index2new_09-over.gif");
    preloadFlag = true;
    }
    }
    // -->
    </SCRIPT>


    thanks for the advise

  2. #2
    Under Construction Poop_Shoot's Avatar
    Join Date
    Jul 2003
    Location
    Sacramento, CA
    Posts
    330
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks preloaded to me! When do you call the preloaded funtion! You should just not have it in a funtion! Place it in the head and it will be one of the first things to load an cache! Try something like this!


    Code:
    pix=["pix1.jpg","pix2.jpg","pix3.jpg"];
    pixs=[];
    if(document.images){
    for(var i in pix){
    pixs[i]=new Image();
    pixs[i].src=pix[i];
    }}


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
  •