Friday, August 26, 2005

Javascript: Preload Images

Based on Macromedia's js function, but rewritten for clarity. I would never actually use this, but since I took the time to clarify it:

// JS: fx preload_images()
function preload_images() {

var doc = document;

if ( doc.images ) {

if ( !doc.IMGS ) {

doc.IMGS = new Array();
var i;
var IMGS_len = doc.IMGS.length;
var IMGS_args = preload_images.arguments;

for ( i=0; i < IMGS_args.length; i++ ) {
if ( IMGS_args[i].indexOf("#") != 0 ) {
doc.IMGS[IMGS_len] = new Image;
doc.IMGS[IMGS_len++].src = IMGS_args[i];
}
}
}
}
} // end FX

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home