Window events are the signals from browser window indicating some change has happened, like onLoad, onResize, onOffline, etc. The BOM handlers are properties of Window object meant for handling such events. Whereas HTML DOM Event handlers are functions registered to handle different events on HTML elements like button click, form load etc.

The BOM handlers and their utility are listed below:

  • onload -   executes the script when the web-page is finished loading
  • onerror – executes the script when error occurs on web-page.
  • onafterprint – executes the script when a document is printed.
  • onbeforeprint – executes script before document is printed.
  • onhashchange – executes script, when anchor part of the webpage changes.
  • onpagehide – executes script when user navigates away from the webpage.
  • onbeforeunload - executes the script when the web-page is about to be unloaded.
  • onmessage – executes script when a message is triggered.
  • onoffline – executes when browser starts to work after becoming offline.
  • ononline - executes when browser starts to work after becoming online.
  • onpageshow – executes the script when user navigates to a page.
  • onpopstate – executes script when window’s user history changes.
  • onresize – script is executed when browser window is resized.
  • onstorage – script is run when web storage area is updated.
  • onunload – script is executed when the window is closed.

More about these events read here.

The onerror event handler example

The onload event handler example

The onresize event handler example


›› go to examples ››