View Full Version : pre load images?

10-10-2007, 09:52 PM
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?

10-11-2007, 03:55 AM

10-11-2007, 04:20 AM
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:

<script type="text/javascript">
//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();

10-11-2007, 07:05 PM
Thanks, didnt think about using the hidden layer :rolleyes: