Multiple onLoad 2
General
Need to load several functions after the page loads? Use this snippet to call several functions using the onLoad event handler. Easy to use.
Notes
- Created by: Simon Willison
- Web Site: http://simon.incutio.com/
- Posted: June 29, 2007
See the notes at: "Executing JavaScript on Page Load"
Source Code
Paste this source code into the designated areas.
External file
Paste this code into an external JavaScript file named: multipleOnload.js and load it last. Or, if you use one file for several scripts, you can add it to the bottom of page.
Head
Paste this code into the HEAD section of your HTML document.


Leave a Response
(4 comments)Well, that is what it does here. As each onload function listed in the script is encountered, it is executed. Then, it moves on to the next one.
How do keep 3 onload functions from executing at once? I want to execute them sequentially...when one completes execution I want to begin execution of the next one?.
Sure, you would want to enter the name of the function to load, e.g.,[br /][br /]Use this one:[br /]addLoadEvent(yourFunction);[br /][br /]or this one:[br /][br /]addLoadEvent(function() {[br /]yourFunctionHere();[br /]});
addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);[br /]addLoadEvent(function() {[br /] functionHere();[br /]});[br /]That bit at the end seems to imply to my inexperienced mind that I should enter something here.[br /][br /]Not quite sure what to do. Can you help?