Make an Image preloader script

This isn’t really as much a how to as a copy and paste job but as long as it works for you hopefully you’ll be happy.

Step 1:
Open up your desired vB template or html file. Add the JS opening tags:

HTML Code:
<script type="text/javascript"><!--

Now we need to define the actual image loading function:

Code:
function newImage(arg) {    if (document.images) {        rslt = new Image();        rslt.src = arg;        return rslt;    }}

Next we define the “other” image preloading function.

HTML Code:
var preloadFlag = false;function preloadImages() {    if (document.images) {        image = newImage("X");        preloadFlag = true;    }

}

Change X to the path of your image.
Then finish off the JS:

HTML Code:
//--></script>

Now you need to trigger the image preloader to do that you need to put the following in your <body> tag:

HTML Code:
onload="preloadImages();"

And your done

About Barry

Enthusiastic about Internet marketing i thought it would be fitting to think about starting a New IM forum , I Also have a keen interest in Network management of which Bandwidth Splitter are something im currently playing with.

Subscribe

Subscribe to our e-mail newsletter to receive updates.

No comments yet.

Leave a Reply