The difference is that window.onload is defined in the DOM Level 0 event model and erases all previously registered events. This is a βnativeβ call from the old API.
Event.observe from the prototype javascript template will determine the best available event certificate. Facade. In modern browsers addEventListener will be called - attachEvent in the case of Internet Explorer below version 9. On older browsers, onload will be called.
Obviously, the facade will choose the best available option, for example, Event.observe for the prototype or .load in the case of jQuery, for example.
Methods from the DOM Level 2 event model are preferable to methods of the DOM Level 0 model, since they act as observers and do not erase previous handlers.
source share