Click to See Complete Forum and Search --> : Multiple "onLoad" events


rizakag
02-04-2003, 01:10 PM
Is it possible to use more than one onLoad event? I have two javascripts I want to use on one web page, and they both have onLoad events. It doesn't work, and a coworker is telling me it can't be done. I won't believe that until I find out for sure!

gil davis
02-04-2003, 01:41 PM
No. You have to combine them into one event. The easiest way is to use a semicolon to separate them:

onload="function1();function2()"

rizakag
02-04-2003, 01:46 PM
Problem is, they're both external .js files with calls to them in the html document.

Now what:confused:

gil davis
02-04-2003, 02:19 PM
Then you'll have to fix it, won't you?

The onload event is just like any other variable. If you equate it to something, then what ever used to be there is replaced with the new thing.

So regardless of how many onloads there are in external files, assuming they are in the HEAD section, putting a new one into the BODY tag that combines the two will fix your dilemma. The one in the BODY tag will override the ones in the external files.

rizakag
02-04-2003, 02:43 PM
"Then you'll have to fix it, won't you?" I hope that wasn't meant to be rude, because it sure sounded like it.

OK, obviously this problem is too much for a forum. I probably didn't explain it well enough, nor did I explain that I strictly find Javascripts and edit them to meet my needs. I'm technical enough to do that, but not technical enough to understand anything in your post.

So, I guess I'll find another way to accomplish what I'm trying to do. Sorry to have bothered you.