Welcome to WebmasterWorld Guest from

Forum Moderators: mack

Message Too Old, No Replies

combining onload events

9:29 pm on Mar 28, 2003 (gmt 0)

New User

10+ Year Member

joined:Mar 5, 2003
votes: 0

I want to combine two onload event in the body tag: A random image onload event and a preload onload event. However, I get a script error. Here is the code:

onload="rotateImage('rImage')" onLoad="MM_preloadImages('images/bar_r1_c1_f2.gif','images/bar_r2_c1_f3.gif','images/bar_r3_c1_f4.gif','images/bar_r4_c1_f5.gif','images/bar_r5_c1_f6.gif');"

Can anyone help me?

9:33 pm on Mar 28, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
votes: 0

Instead of using two onLoad event handlers, hook the two functions together with a semicolon:


1:19 am on Apr 11, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 25, 2002
votes: 0

Or (as I usually recommend) to save on ugly code bloat, put both function calls into a container function, and put it all in an external javascript, so instead of :

<body onload="rotateImage('rImage')" onLoad="MM_preloadImages('images/bar_r1_c1_f2.gif','images/bar_r2_c1_f3.gif','images/bar_r3_c1_f4.gif','images/bar_r4_c1_f5.gif','images/bar_r5_c1_f6.gif');">

you end up with

<body onload="loadpage();">


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members