What exactly is the difference between the window.onload event and the onload event of the body tag? when do I use which and how shoul
I prefer, generally, to not use the > event. I think it's cleaner to keep behavior separated from content as much as possible.
That said, there are occasions (usually pretty rare for me) where using body onload can give a slight speed boost.
I like to use Prototype so I generally put something like this in the > of my page:
document.observe("dom:loaded", function(){
alert('The DOM is loaded!');
});
or
Event.observe(window, 'load', function(){
alert('Window onload');
});
The above are tricks I learned here. I'm very fond of the concept of attach event handlers outside of the HTML.
(Edit to correct spelling mistake in code.)