Call a function when a user unloads the document:
The onunload event occurs once a page has unloaded (or the browser window has been closed).
onunload occurs when the user navigates away from the page (by clicking on a link, submitting a form, closing the browser window, etc.).
Note: The onunload event is also triggered when a user reloads the page (and the onload event).
Note: Due to different browser settings, this event may not always work as expected.
|Event type:||UiEvent if generated from a user interface, Event otherwise.|
|DOM Version:||Level 2 Events|