View Full Version : Test Cache

07-27-2007, 04:37 PM
I am working on a web gallery script that uses a javascript crossfade after preloading images. The problem I have is the crossfade script is written in such a way as to only allow one image to crossfade at a time. Any subsequent requests to crossfade an image while the first one is still fading are ignored. This is not a problem until the images are cached, in which case they preload all at the same time and only the first image crossfades and the rest stay on the loading image.

The only solution I can see working is to test the page to see if it is cached and if so skip the crossfades and simply change the image source. Is there any way to do this in javascript?

07-27-2007, 04:44 PM
I wouldn't do that... what you really want to test is whether the crossfade worked or not. If not, just wait a little while (say half a second) and try again. A well-written script will allow you to do this; a badly-written one will have to be modified. Either way, we'd have to see the script to work out how to do it.

07-27-2007, 04:47 PM
The script is here:

The implementation is here:

07-28-2007, 02:14 PM
Ok, I figured it out. I created a variable "fade" with the value "notDone". And then at the end of the crossfade script i set it to "done" then I put a function on my page that tested the value of fade. If fade != done it used the setTimeout function to pause for half a second or so and try again.