I am pre-loading some images and then using them in a lightbox. The problem I have is that although the images are loading, they aren\'t being displayed by the browser.
Chrome might not be preloading them as it's writing to the DOM with no display, so it might be intelligent enough to realise it doesn't need to be rendered. Try this instead:
var preloaded = new Array();
function preload_images(){
for (var x = 0; x < preload_images.arguments.length; x++)
{
preloaded[x] = new Image();
preloaded[x].src = preload_images.arguments[x];
}
}
The Javascript Image object has a lot of useful functions as well you might find useful:
http://www.javascriptkit.com/jsref/image.shtml
onabort()
Code is executed when user aborts the downloading of the image.
onerror()
Code is executed when an error occurs with the loading of the image (ie: not found). Example(s)
onload()
Code is executed when the image successfully and completely downloads.
And then you also have the complete property which true/false tells you if the image has fully (pre)loaded.