When a page completes loading, the "load" event fires on the window and the document body objects. 
Similar to focus-related events, loading events do not propagate.
When a page is closed or navigated away from (for example by following a link), a "beforeunload" event fires. This event prevents the user from accidentally losing work by closing a document. This can be done by returning a string from the handler which will be used in a dialog that asks the user and ensures if they want to stay on the page or leave it.
