Welcome to WebmasterWorld Guest from 107.21.159.218

Forum Moderators: brotherhood of lan & mack

Message Too Old, No Replies

combining onload events

     

deltron23

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

10+ Year Member



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?

tedster

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

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



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

onload="rotateImage();MM_preloadImages();"

Filipe

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

10+ Year Member



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();">

 

Featured Threads

Hot Threads This Week

Hot Threads This Month