Web Hosting Talk







View Full Version : Preload images


koorb
11-19-2003, 08:10 PM
I am trying to protect and preload images for a site i am doing for a client

www.thechilli.co.uk/clients/art_gecko

I am pulling images from a protected directory using a php script simply with a readfile() function and this works, I am using Macromedias - MM_preloadImages() function,


function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


But everytime I load the page it seems to reload the images as if they are all new. so its worse than not `preloading`!
Little help?

TIA

John[H4Y]
11-19-2003, 09:45 PM
Pre-loading images is different than caching them so they load off the user's HD on the next page load. The browser controls caching. It may destroy the browser's ability to load the image from cache if it is pre-loaded.

Jeanco
11-20-2003, 12:10 AM
I do't know what your problem is, but I used a preloading script at www.artucreative.com and it worked fine. The images take long enough to load you should be able to view the source before it switches pages.

Hope it helps.

pack tloss
11-20-2003, 04:26 PM
I just use either :

A) A hidden CSS layer and put the images on there.
B) Use (frames) with a height.width of 1, and put the images in there.

I don't like using javascript to preload images :P

koorb
11-20-2003, 08:09 PM
Originally posted by pack tloss
A) A hidden CSS layer and put the images on there.


Oh cool, good idea? I have been looking at css latley (just a bit) is css2 in common place ? how do you check what css your browser supports ?

delirium
11-20-2003, 09:07 PM
Originally posted by pack tloss

A) A hidden CSS layer and put the images on there.


My preferred method as well

pack tloss
11-21-2003, 01:49 AM
just do this

<style>
.thelayer { visibility: hidden; }
</style>

then where u have the images.
<div class=thelayer> <img src=black.gif> </div>