Image Preloading Script

Blogged in Programming, Web Design, Internet by Matt on Thursday December 1, 2005

In my previous post regarding CSS Image Rollovers there was question asked whether or not the image is preloaded or not. The image is not preloaded, so on the first visit to the page the image will have to load, causing a brief blank spot to be where the button is. To resolve this we simply need to use a JavaScript based Image Preloading Script which can be found below.

var imageload=new Array()
function preload(){
for (i=0;i
imageload[i]=new Image()
imageload[i].src=arguments[i]
}
}

preload(”http://www.name.com/name.jpg”,”http://www.name.com/name2.jpg”, “http://www.name.com/name3.jpg”)

When you use the above script, be sure to change the location of the images in the above URLs to reflect where your images are located.

Popularity: 10% [?]