Showing posts with label JavaScript Events. Show all posts
Showing posts with label JavaScript Events. Show all posts

Thursday, February 18, 2016

Types of JavaScript Events

W3C DOM Events

DOM Level 2 UIEvent: user interface events occur for interactions with browser's window
type event description target
load Fires when HTML and all resources of a web page have finished loading document, window
unload Fires when web page is unloading for a new page requested body, window
error Fires when browser encounter a JS error or resource does not exist (inconsistent support)
resize Fires repeatedly as browser's window is being resized window
scroll Fires repeatedly as user scrolls web page document, element

Usage:

  • The load event is commonly used to trigger scripts that access the content of a page. It can cause the page to look slow, because it is raised only when all images are fully loaded.
  • As resize and scroll events fire repeatedly, do not use them to trigger complicated code.

Thursday, February 11, 2016

JavaScript Events

Types of Events

In a browser events are dispatched to objects to signal that something has happened, such as network activity or user interaction.
  • W3C DOM Events Interfaces
    • UIEvent: user interface events occur for an interaction with browser's window
    • FocusEvent: occur when an element (link or form field) gains or loses focus
    • MouseEvent: occur when user uses mouse, touchscreen, trackpad
    • KeyboardEvent: occur when user uses keyboard
    • [deprecated] MutationEvent: occur for a modification of DOM structure or DOM node
    • MutationObserver: occur for a modification of DOM structure or DOM node
  • W3C HTML5 Events Interfaces
    • FormEvent: occur for an interaction with form element
    • Various Interfaces: occur for an interaction with web page
  • Vendor Specific BOM Events
    • Events that deals with touchscreen and accelerometer