Re: Rollovers - images don't preload - why?
by KeithWBell(at)aol.com
|
Date: |
Wed, 31 May 2000 12:06:04 EDT |
To: |
choicemag(at)hotmail.com, hwg-techniques(at)hwg.org |
|
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;
i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
MM_preloadImages(
'/images/HomePage_f2.gif',
'/images/WhatsNew_f2.gif',
'/images/Comment_f2.gif',
'/images/NewReleases_f2.gif',
'/images/MajorEvents_f2.gif',
'/images/BillMonroe_f2.gif',
'/images/Forums_f2.gif',
'/images/Teachers_f2.gif',
'/images/Instruments_f2.gif',
'/images/Societies_f2.gif',
'/images/Links_f2.gif'
)
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:
http://wolves.dreamhost.com/web/js/im01.htm
or check out Ryan Holsten's "In search of the perfect rollover" on A List
Apart at:
http://www.alistapart.com/stories/rollover/rollover1.html
Regards
Keith Bell
In a message dated 31/05/00 16:27:40 GMT Daylight Time, choicemag(at)hotmail.com
writes:
> 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,
it
> all looks like gobbledegook to me. In the past I've been able to
understand
>
> 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
javascript
> than I can tell me what's wrong
>
> The images are swapping ok, but the mouseover images aren't preloading.
The
>
> 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