Multiple onload events in the bidy tag

E

Evertjan.

Michael Landberg wrote on 22 jun 2007 in comp.lang.javascript:
is it possible to load multiple onload events in the body tag?

onload events are not "loaded" themselves.

<body onload='action1();action2();'>
 
M

Michael Landberg

Michael Landberg wrote on 22 jun 2007 in comp.lang.javascript:


onload events are not "loaded" themselves.

<body onload='action1();action2();'>

Hi

Yes, excuse me for not making myself clear. I meant ofcourse calling
multiple functions from the body event.
But thank you for the answer.
 
E

ed

A better way would be to attach an event to the body, and then simply
call one function:

function onLoadFunction () {
actionOne();
 
E

ed

You could also just attach a function to onload that calls two or more
actions:

<body onload="onLoadFunction();">

function onLoadFunction() {
actionOne();
actionTwo();
 
E

Evertjan.

ed wrote on 22 jun 2007 in comp.lang.javascript:
[Please do not toppost on usenet]
You could also just attach a function to onload that calls two or more
actions:

<body onload="onLoadFunction();">

function onLoadFunction() {
actionOne();
actionTwo();
.
.
.
actionOneHundred();
}

Indeed you could, but should the OP?
Keeps more JS out of the HTML which is cleaner.

An argument, be it a subjective one, not really related to the OQ.
You should also think

You could, should the OP?
about attaching the events from inside the JS. You can use the code
here:

http://therealcrisp.xs4all.nl/upload/addEvent_dean.html

No, I don't think that is up to the OP's level.
 
E

Evertjan.

ed wrote on 22 jun 2007 in comp.lang.javascript:

[please do not quote signatures]

[Please do not toppost on usenet]
A better way would be to attach an event to the body, and then simply
call one function:

function onLoadFunction () {
actionOne();

Why would that be a "better" way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top