[thelist] Appending actions to event handlers in Javascript

Jeff Howden jeff at jeffhowden.com
Tue Oct 21 20:13:44 CDT 2003


tom,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Tom Dell'Aringa
>
> Hope I'm not oversimplying this or missed the problem
> but to me you have two options.
>
> 1:
>
> window.onload = doStuff;
>
> function doStuff()
> {
>    doSomething();
>    doThis();
> }
>
> or
>
> body onload="doSomething(); doThis();"
>
> Unless there is some reason they can't be together?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

he wants to add them programmatically to a stack of things that gets
executed when the onload event handler fires.

there are additional options though.

put the <script> block in the body of the document immediately following the
html it interacts with.  now it doesn't need to be called via the onload
event handler.

use attachEvent()/addEventListener() methods.

http://www.doxdesk.com/software/js/event.html

[warning: there's no way to guarantee what order the statements are
executed.]

.jeff

------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/



More information about the thelist mailing list