This is an update to a previous article written way back in 2003 "Managing multiple onLoad events in JavaScript".
The article describes how to create an array of onload (window.onload) events in order to queue each event and enable the browser to perform onload sequentially. However this can all be forgotten in preference to the Prototype Javascript Framework and the useful Event Observe method.
Use Event.observe instead of using <body onload="return myFunction()"> or DOM Level-0 event property window.onload = myFunction;
Example
-
Event.observe(window, 'load', function() { myFunction.init() });
-
Event.observe(window, 'load', function() { myFunction2.init() });
- Filed under:
- Scripting
- JavaScript
- Prototype
- Posted by:
- James Griffin
- Dated:
- June 16, 2007
- Tweet