spacer
HOME HTML CSS JAVASCRIPT JQUERY XML ASP.NET PHP SQL MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

JS & DOM Reference

Overview

JavaScript Objects

JS Array
JS Boolean
JS Date
JS Math
JS Number
JS String
JS RegExp
JS Global

Browser Objects

Window
Navigator
Screen
History
Location

Core DOM Objects

DOM Node
DOM NodeList
DOM NamedNodeMap
DOM Document
DOM Element
DOM Attr

HTML DOM Objects

DOM Document
DOM Events
DOM Elements

DOM Anchor
DOM Area
DOM Base
DOM Body
DOM Button
DOM Form
DOM Frame/br
DOM Frameset
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Meta
DOM Object
DOM Option
DOM Select
DOM Style
DOM Table
DOM td / th
DOM tr
DOM Textarea

HTML DOM Events

« Previous
Next Reference »

HTML DOM Events

HTML DOM events allow JavaScript to register different event handlers on elements in an HTML document.

Events are normally used in combination with functions, and the function will not be executed before the event occurs (such as when a user clicks a button).

Tip: The event model was standardized by the W3C in DOM Level 2.


HTML DOM Events

DOM: Indicates in which DOM Level the property was introduced.

Mouse Events

Property Description DOM
onclick The event occurs when the user clicks on an element 2
ondblclick The event occurs when the user double-clicks on an element 2
onmousedown The event occurs when a user presses a mouse button over an element 2
onmousemove The event occurs when the pointer is moving while it is over an element 2
onmouseover The event occurs when the pointer is moved onto an element 2
onmouseout The event occurs when a user moves the mouse pointer out of an element 2
onmouseup The event occurs when a user releases a mouse button over an element 2

Keyboard Events

Attribute Description DOM
onkeydown The event occurs when the user is pressing a key 2
onkeypress The event occurs when the user presses a key 2
onkeyup The event occurs when the user releases a key 2

Frame/Object Events

Attribute Description DOM
onabort The event occurs when an image is stopped from loading before completely loaded (for <object>) 2
onerror The event occurs when an image does not load properly (for <object>, <body> and <frameset>)  
onload The event occurs when a document, frameset, or <object> has been loaded 2
onresize The event occurs when a document view is resized 2
onscroll The event occurs when a document view is scrolled 2
onunload The event occurs once a page has unloaded (for <body> and <frameset>) 2

Form Events

Attribute Description DOM
onblur The event occurs when a form element loses focus 2
onchange The event occurs when the content of a form element, the selection, or the checked state have changed (for <input>, <select>, and <textarea>) 2
onfocus The event occurs when an element gets focus (for <label>, <input>, <select>, textarea>, and <button>) 2
onreset The event occurs when a form is reset 2
onselect The event occurs when a user selects some  text (for <input> and <textarea>) 2
onsubmit The event occurs when a form is submitted 2

Event Object

Constants

Constant Description DOM
CAPTURING_PHASE The current event phase is the capture phase (3) 1
AT_TARGET The current event is in the target phase, i.e. it is being evaluated at the event target (1) 2
BUBBLING_PHASE The current event phase is the bubbling phase (2) 3

Properties

Property Description DOM
bubbles Returns whether or not an event is a bubbling event 2
cancelable Returns whether or not an event can have its default action prevented 2
currentTarget Returns the element whose event listeners triggered the event 2
eventPhase Returns which phase of the event flow is currently being evaluated 2
target Returns the element that triggered the event 2
timeStamp Returns the time (in milliseconds relative to the epoch) at which the event was created 2
type Returns the name of the event 2

Methods

Method Description DOM
initEvent() Specifies the event type, whether or not the event can bubble, whether or not the event's default action can be prevented 2
preventDefault() To cancel the event if it is cancelable, meaning that any default action normally taken by the implementation as a result of the event will not occur 2
stopPropagation() To prevent further propagation of an event during event flow 2

EventTarget Object

Methods

Method Description DOM
addEventListener() Allows the registration of event listeners on the event target (IE8 = attachEvent()) 2
dispatchEvent() Allows to send the event to the subscribed event listeners (IE8 = fireEvent()) 2
removeEventListener() Allows the removal of event listeners on the event target (IE8 = detachEvent()) 2

EventListener Object

Methods

Method Description DOM
handleEvent() Called whenever an event occurs of the event type for which the EventListener interface was registered 2

DocumentEvent Object

Methods

Method Description DOM
createEvent()   2

MouseEvent/KeyboardEvent Object

Properties

Property Description DOM
altKey Returns whether or not the "ALT" key was pressed when an event was triggered 2
button Returns which mouse button was clicked when an event was triggered 2
clientX Returns the horizontal coordinate of the mouse pointer, relative to the current window, when an event was triggered 2
clientY Returns the vertical coordinate of the mouse pointer, relative to the current window, when an event was triggered 2
ctrlKey Returns whether or not the "CTRL" key was pressed when an event was triggered 2
keyIdentifier Returns the identifier of a key 3
keyLocation Returns the location of the key on the advice 3
metaKey Returns whether or not the "meta" key was pressed when an event was triggered 2
relatedTarget Returns the element related to the element that triggered the event 2
screenX Returns the horizontal coordinate of the mouse pointer, relative to the screen, when an event was triggered 2
screenY Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was triggered 2
shiftKey Returns whether or not the "SHIFT" key was pressed when an event was triggered 2

Methods

Method Description W3C
initMouseEvent() Initializes the value of a MouseEvent object 2
initKeyboardEvent() Initializes the value of a KeyboardEvent object 3

« Previous
Next Reference »

w3schools.com
on Facebook
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$3.98 Unlimited Hosting
250+ Hosting Apps
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
FREE Website Creator
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, jQuery, XML, PHP, ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE


gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.