Forum Moderators: open

Message Too Old, No Replies

Multiple OnLoad attributes

         

kiwanji

3:02 pm on Mar 27, 2003 (gmt 0)

10+ Year Member



I am trying to use two different OnLoad attributes in my <body> tag. I thought it would not work and I was right unfortunately. Question is: how would I make this work?

Here is the tag:

<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#0066FF" alink="#2E8B57" onLoad="MM_preloadImages('../images/sidebar/menu_down.jpg','../images/sidebar/coupons_down.jpg','../images/sidebar/party_down.jpg')" OnLoad="rotateImage('rImage')">

First OnLoad is for a roll over image to work, second is for a rotating image javascript. I am not sure if I even need the onload for the rollovers. If I get rid of that onload will the rollovers stop working? If I need them both how do I combine them?

Thanks!

Birdman

3:32 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How 'bout making a separate function that triggers the other two.

function trigger{
MM_preloadImages('arg','arg2','arg3')
rotateImage('arg4')
}

<body onload="trigger(arg,arg2,arg3,arg4)">

Something like that, my js syntax is not good.

tedster

5:12 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If I get rid of that onload will the rollovers stop working?

If rollover images are not preloaded, then the rollovers will have a time delay when the first mouseover occurs. Smehow the rollover images need to be cached before the first mouseover.

It is possible to preload images without calling a special function onLoad the way this Dreamweaver script does. See Bare Bones rollover [webmasterworld.com] for details.

It is also possible, as Birdman suggests, to combine the functions. One way would be first to define the MM_preloadImages(), and then add an extra line to your definition of the rotateImage() function that calls MM_preloadImages() .

That way, onLoad you only need to call the rotateImage() function, but when it executes, it calls the preloader as part of its job.

[edited by: tedster at 5:56 pm (utc) on Mar. 27, 2003]

BlobFisk

5:53 pm on Mar 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The above suggestions of combining the functions are much better than what I'm about to suggest - but for a quick and dirty solution, try seperating the two functions with a semi-colon in the onLoad tag:

onLoad="MM_preloadImages('<code cut for clarity>') ; rotateImage('rImage')">

It may well do the trick....