homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

combining onload events

10+ Year Member

Msg#: 439 posted 9:29 pm on Mar 28, 2003 (gmt 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?



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

Msg#: 439 posted 9:33 pm on Mar 28, 2003 (gmt 0)

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



10+ Year Member

Msg#: 439 posted 1:19 am on Apr 11, 2003 (gmt 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();">

Global Options:
 top home search open messages active posts  

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved