Click to See Complete Forum and Search --> : multiple onload event handlers


pixelative
11-23-2002, 09:09 PM
I hope someone can help with what must be a simple query:

How do I put two onload event handlers in the body tag so that they work.

One's for a popup window:

onLoad="popupWin()"

the other to preload images for roll-overs :

onLoad="MM_preloadImages('images/home1.gif',' etc..etc..

Combining the 2 is the problem and I can't find the solution in the 2 JS books I have?

Thanks...

Beach Bum
11-23-2002, 09:15 PM
here is an example of one of mine with two onload functions that works

<body oncontextmenu="return false" OnLoad="animate(), randomdir()">

pixelative
11-23-2002, 09:23 PM
this is what I have now...

<body bgcolor="#FFFFFF" text="#000000" background="images/bg4.gif" onLoad="MM_preloadImages('images/home1.gif','images/workshops1.gif','images/bio1.gif','images/sculpture1.gif','images/studio%20tour1.gif')">

and I want to add this onload below to the above..

onLoad="popupWin()"

so that both work together...

?????

Beach Bum
11-23-2002, 09:35 PM
what you have is not what i have. look at my example again. i have two put functions together in the onload. they are separated by a coma and a space in my example. look again.

so in your case, before the " put a , pupupWin() then the "

pixelative
11-23-2002, 09:49 PM
thanks for you post, Beach Bum, it works and i see how and why....

regards........

Charles
11-24-2002, 05:25 AM
Using a comma might work, but it shouldn't. The value of the event handler attribute is supposed to be valid script. Use a semi-colon if you want to be sure that it works on more browsers.

pixelative
11-24-2002, 05:55 AM
Okay then...on closer inspection it doesn't work as I said it did...so here again is the whole thing if anyone can help.

The code I have now....

<body bgcolor="#FFFFFF" text="#000000" background="images/bg4.gif" onLoad="MM_preloadImages('images/home1.gif','images/workshops1.gif','images/bio1.gif','images/sculpture1.gif','images/studio%20tour1.gif')">

and i want to add this below to the above so that the roll-overs work and the window pops up when the page loads...

onLoad="popupWin()"

I'm getting an error message and the rollovers won't work the way I combined the 2 at the present.

btw...if it makes any difference, the pop-up script is an external file.

thanks to all

Charles
11-24-2002, 06:23 AM
<body bgcolor="#FFFFFF" text="#000000" background="images/bg4.gif" onLoad="MM_preloadImages('images/home1.gif','images/workshops1.gif','images/bio1.gif','images/ sculpture1.gif','images/studio%20tour1.gif'); popupWin()">

Beach Bum
11-24-2002, 02:24 PM
after some testing i see that either a , or a ; will work for me

but if a ; is the correct syntax i change mine to a ;