Which is more widely supported: window.onload or document.onload?
window.onload
In some browsers it now takes over the role of document.onload and fires when the DOM is ready as well.
document.onload
window.onload appears to be the most widely supported. In fact, some of the most modern browsers have in a sense replaced document.onload with window.onload.
Browser support issues are most likely the reason why many people are starting to use libraries such as jQuery to handle the checking for the document being ready, like so:
$(document).ready(function() { /* code here */ });
$(function() { /* code here */ });
For the purpose of history. window.onload vs body.onload:
A similar question was asked on codingforums a while back regarding the usage of
window.onloadoverbody.onload. The result seemed to be that you should usewindow.onloadbecause it is good to separate your structure from the action.