Re: Rollovers - images don't preload - why?

by KeithWBell(at)

 Date:  Wed, 31 May 2000 12:06:04 EDT
 To:  choicemag(at),
  todo: View Thread, Original
Hi Mike

Just took a quick look at your page: your mouseover images are actually 
preloading - well, sort of. Your problem is that you are calling the 
"preload" function from an onLoad event in the BODY tag - so it won't execute 
until AFTER the rest of the page has completely loaded.

Instead of making the function call from the onLoad event, just put it in the 
HEAD section after defining the preload function, like this:

/* Functions that handle preload. */
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; 
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}


and it should have the desired effect. There are other (and possibly 
simpler!) ways to do this, but this should work without you re-hashing much 
code. By the way, another HWG member Larry Coats has a good tutorial on 
rollovers on his site at:

or check out Ryan Holsten's "In search of the perfect rollover" on A List 
Apart at:

Keith Bell

In a message dated 31/05/00 16:27:40 GMT Daylight Time, choicemag(at) 

> I'm preparing a site, using rollovers produced from Macromedia Fireworks3.  
>  It's the first time I've done rollovers that way, and to tell the truth, 
>  all looks like gobbledegook to me.  In the past I've been able to 
>  the javascript written by these apps, but in this case, its totally 
>  impenetrable for me.
>  And it's not working right.  I hope someone who knows more about 
>  than I can tell me what's wrong
>  The images are swapping ok, but the mouseover images aren't preloading.  
>  page is going to the site to get the images as the mouse goes over it.  SO 
>  it's not swapping fast.

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA