Create a page called onload.html. Change the opening body tag to look like this:
Create the function and inside it put a simple alert (say Hi maybe). Try the page and you should get the hello as soon as the body element loads in the browser. If you attach the event to other elements you will see the message when they load instead of when the page as a whole loads.