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
They both work the same. However, note that if both are defined, only one of them will be invoked. I generally avoid using either of them directly. Instead, you can attach an event handler to the load event. This way you can incorporate more easily other JS packages which might also need to attach a callback to the onload event.
Any JS framework will have cross-browser methods for event handlers.