HTML Window Event Handler Attributess


HTML window event handlers are those that triggered by changes happened at the page level. It is applicable to the <body> tag.

For example, the following event handler "onload" will show an alert window when page loads.

<body onload="alert('test');">


Attribute list of <body> tag:
Attribute Names Events
onafterprint After printing
onbeforeprint Before printing
onbeforeonload Before web page loads
onblur Window loses focus
onerrorAn error encountered
onfoucsWindow get focus
onhaschangeContent revised
onloadWhen page loads
onmessageMessage display
onofflinePage is offline
ononlinePage is online
onpagehideWhen window became hidden
onpageshowWhen window became shown
onpopstateURL change
onredoRedo command executed
onresizeWindow resized
onstorageWhen page loads
onundoUndo command executed
onunloadLeaves the page

Note: Except onblur, onfocus, onload, all other attributes are only work for HTML5.