You are here: Reference > appendix > javascript > interfaces

Interfaces in JavaScript

An interface allows developers to add new functionalities to objects that implement it. For example, the HTMLAnchorElement interface lets you define new properties and methods on all anchor elements.

In the followings, you can find the interfaces in alphabetical order, the interface inheritance hierarchy, browser support information and the objects that implement them. At the bottom of this page, a few examples demonstrate the use of interfaces.

Note: Internet Explorer supports interfaces from version 8.
Interfaces in alphabetical order:
Interface inheritance hierarchy:
Interface Support Object that implements it in JavaScript
BarProp
BarProp
BoxObject
BoxObject
ClientRect
939.54
TextRectangle
ClientRectList
939.54
TextRectangles
Counter
Counter
Crypto
crypto
CSSRule
9
CSSRule
CSSCharsetRule
CSSCharsetRule
CSSFontFaceRule
9
CSSFontFaceRule
CSSImportRule
9
CSSImportRule
CSSMediaRule
9
CSSMediaRule
CSSPageRule
9
CSSPageRule
CSSStyleRule
8
CSSStyleRule
CSSRuleList
8
cssRules
CSSStyleDeclaration
8
CSSStyleDeclaration, currentStyle, style
ComputedCSSStyleDeclaration
CSSStyleDeclaration
CSSStyleSheet
8
styleSheet
CSSValue
CSSValue
CSSPrimitiveValue
CSSPrimitiveValue
CSSValueList
CSSValueList
DOMException
9
DOMException
DOMImplementation
8
implementation
DOMParser
9
DOMParser
DOMStringList
DOMStringList
Event
8
event
If you need a summary of events and event types, see the page for Events in JavaScript.
Use the createEvent method with 'Event' type to create and the initEvent method to initialize an event object that implements this interface.
BeforeUnloadEvent
9
event
The createEvent method does not support this type of event object.
CustomEvent
9
event
Use the createEvent method with 'CustomEvent' type to create and the initCustomEvent method to initialize an event object that implements this interface.
MessageEvent
9310.6
event
Use the createEvent method with 'MessageEvent' type to create and the initMessageEvent method to initialize an event object that implements this interface.
MutationEvent
9
event
Use the createEvent method with 'MutationEvent' type to create and the initMutationEvent method to initialize an event object that implements this interface.
OverflowEvent
event
Use the createEvent method with 'OverflowEvent' type to create and the initOverflowEvent method to initialize an event object that implements this interface.
PopupBlockedEvent
event
Use the createEvent method with 'PopupBlockedEvents' type to create and the initPopupBlockedEvent method to initialize an event object that implements this interface.
ProgressEvent
3.5
event
Use the createEvent method with 'ProgressEvent' type to create and the initProgressEvent method to initialize an event object that implements this interface.
StorageEvent
910.5
event
Use the createEvent method with 'StorageEvent' type to create and the initStorageEvent method to initialize an event object that implements this interface.
SVGEvent
event
Use the createEvent method with 'SVGEvent' type to create and the initEvent method to initialize an event object that implements this interface.
UIEvent
9
event
Use the createEvent method with 'UIEvent' type to create and the initUIEvent method to initialize an event object that implements this interface.
CompositionEvent
9
event
Use the createEvent method with 'CompositionEvent' type to create and the initCompositionEvent method to initialize an event object that implements this interface.
FocusEvent
9
event
Use the createEvent method with 'FocusEvent' type to create and the initFocusEvent method to initialize an event object that implements this interface.
KeyboardEvent
9
event
Use the createEvent method with 'KeyboardEvent' type to create and the initKeyEvent method to initialize an event object that implements this interface.
MouseEvent
9
event
Use the createEvent method with 'MouseEvent' type to create and the initMouseEvent method to initialize an event object that implements this interface.
DragEvent
9
event
Use the createEvent method with 'DragEvent' type to create and the initDragEvent method to initialize an event object that implements this interface.
MouseScrollEvent
3.5
event
Use the createEvent method with 'MouseScrollEvent' type to create and the initMouseScrollEvent method to initialize an event object that implements this interface.
MouseWheelEvent
9
event
Use the createEvent method with 'MouseWheelEvent' type to create and the initMouseWheelEvent method to initialize an event object that implements this interface.
WheelEvent
9
event
Use the createEvent method with 'WheelEvent' type to create and the initUIEvent method to initialize an event object that implements this interface.
Note: The WheelEvent interface inherits from the UIEvent interface in Google Chrome and Safari.
SVGZoomEvent
95
event
Use the createEvent method with 'SVGZoomEvent' type to create and the initUIEvent method to initialize an event object that implements this interface.
TextEvent
9
event
Use the createEvent method with 'TextEvent' type to create and the initTextEvent method to initialize an event object that implements this interface.
XULCommandEvent
event
Use the createEvent method with 'XULCommandEvent' type to create and the initCommandEvent method to initialize an event object that implements this interface.
GeckoActiveXObject
2.0
GeckoActiveXObject
History
8
history
Image
Image
File
3
File
FileList
3
FileList
HTMLCollection
8
all, anchors, applets, areas, cells, children, elements, embeds, forms, images, links, rows, scripts, tBodies
Note: whether the HTMLCollection interface is supported by Firefox, but the previous collections are not inherited from it.
HTMLOptionsCollection
options
Location
8
location
MediaList
9
mediaList
MimeType
mimeType
MimeTypeArray
mimeTypes
NamedNodeMap
8
attributes
Navigator
8
navigator
Node
9
Attr
8
attribute
CDATASection
9
CDATASection
Comment
9
CommentNode
Document
9
HTMLDocument
8
9
document
XMLDocument
XMLDocument
Note: the XMLDocument interface is identical to the Document interface in Safari and Google Chrome.
DocumentFragment
9
DocumentFragment
DocumentType
9
doctype
Element
8
HTMLElement
9
HTMLAnchorElement
8
a
HTMLAppletElement
9
applet
HTMLAreaElement
8
area
HTMLAudioElement
93.5
Audio
HTMLBaseElement
8
base
HTMLBaseFontElement
8
basefont
HTMLBlockquoteElement
blockquote
HTMLBodyElement
8
body
HTMLBRElement
8
br
HTMLButtonElement
8
button
HTMLCanvasElement
9
Canvas
HTMLTableCaptionElement
8
caption
HTMLTableColElement
8
col, colgroup
HTMLDelElement
del
HTMLDirectoryElement
9
dir
HTMLDivElement
8
div, marquee, noframes, noscript
HTMLDListElement
8
dl
HTMLEmbedElement
8
embed
HTMLFieldSetElement
8
fieldset
HTMLFontElement
8
font
HTMLFormElement
8
form
HTMLFrameElement
8
frame
HTMLFrameSetElement
8
frameset
HTMLHeadingElement
8
h1, h2, h3, h4, h5, h6
HTMLHeadElement
8
head
HTMLHRElement
8
hr
HTMLHtmlElement
8
html
HTMLIFrameElement
8
iframe
HTMLImageElement
8
img
HTMLInputElement
8
input:button, input:checkbox, input:file, input:hidden, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text
HTMLInsElement
ins
HTMLIsIndexElement
8
isindex
HTMLLabelElement
8
label
HTMLLegendElement
8
legend
HTMLLIElement
8
li
HTMLLinkElement
8
link
HTMLMapElement
8
map
HTMLMarqueeElement
8
marquee
HTMLMediaElement
93.5
Media
HTMLMenuElement
9
menu
HTMLMetaElement
8
meta
HTMLModElement
9
del, ins
In Firefox, use the HTMLDelElement and HTMLInsElement interfaces instead.
HTMLObjectElement
8
object
HTMLOListElement
8
ol
HTMLOptGroupElement
9
optgroup
HTMLOptionElement
8
option
HTMLParagraphElement
8
p
HTMLParamElement
8
param
HTMLPreElement
9
pre
HTMLQuoteElement
9
blockquote, q
HTMLScriptElement
8
script
HTMLSelectElement
8
select, keygen
HTMLSpanElement
8
abbr, acronym, address, b, bdo, big, blink, center, cite, code, dd, dfn, dt, em, i, kbd, listing, nobr, plaintext, s,
samp, small, span, strike, strong, sub, sup, tt, u, var, xmp
HTMLStyleElement
8
style
HTMLTableElement
8
table
HTMLTableSectionElement
8
tbody, tfoot, thead
HTMLTableCellElement
8
td, th
HTMLTextAreaElement
8
textarea
HTMLTitleElement
8
title
HTMLTableRowElement
8
tr
HTMLUListElement
8
ul
HTMLUnknownElement
8
HTMLVideoElement
93.5
Video
HTMLWBRElement
wbr
Entity
Entity
EntityReference
EntityReference
Text
8
TextNode
NodeFilter
9
Constants are defined in the scope of this interface. See the pages for the whatToShow property and the createNodeIterator and createTreeWalker methods for details.
NodeIterator
93.5
NodeIterator
NodeList
8
NodeList, childNodes
Notation
Notation
Option
Option
Plugin
plugin
PluginArray
plugins
ProcessingInstruction
9
ProcessingInstruction
Range
9
Range
Rect
Rect
CSSRect
Rect
RGBColor
5
RGBColor
CSSRGBColor
RGBColor
Screen
8
screen
Selection
8
selectionRange
Storage
8
Storage
StyleSheetList
8
styleSheets
StyleSheetPage
8
9
page
StyleSheetPageList
8
pages
TreeWalker
9
TreeWalker
Window
8
window
XMLHttpRequest
XMLHttpRequest
XMLSerializer
9
XMLSerializer
XPathNSResolver
XPathNSResolver
XPathResult
XPathResult

Members of the Event interface:

Browser support:
8
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Constants:

The following constants are available in the scope of the Event interface (Event.CAPTURING_PHASE, Event.DBLCLICK, etc.). Using the constants instead of their numeric values results in more readable code.
The following constants represent the processing phases of events and can be used for the values of the eventPhase property.
Name Support Value Description
CAPTURING_PHASE
9
1 The event flow is in capturing phase.
AT_TARGET
9
2 The event flow is in target phase.
BUBBLING_PHASE
9
3 The event flow is in bubbling phase.
The following constants represent event types and some of them can be used for the first parameter of the captureEvents and releaseEvents methods.
Name Support Value
ABORT
0x00400000
BACK
0x20000000
BLUR
0x00002000
CLICK
0x00000040
CHANGE
0x00008000
DBLCLICK
0x00000080
DRAGDROP
0x00000800
ERROR
0x00800000
FOCUS
0x00001000
FORWARD
0x08000000
HELP
0x10000000
KEYDOWN
0x00000100
KEYPRESS
0x00000400
KEYUP
0x00000200
LOAD
0x00080000
LOCATE
0x01000000
MOUSEDOWN
0x00000001
MOUSEDRAG
0x00000020
MOUSEMOVE
0x00000010
MOUSEOUT
0x00000008
MOUSEOVER
0x00000004
MOUSEUP
0x00000002
MOVE
0x02000000
RESET
0x00010000
RESIZE
0x04000000
SCROLL
0x00040000
SELECT
0x00004000
SUBMIT
0x00020000
UNLOAD
0x00100000
XFER_DONE
0x00200000
The following constants represent the ALT, CTRL, META and SHIFT keys that can be used for the modifiers event property. The modifiers property is deprecated and not supported by Internet Explorer, Firefox, Google Chrome, Opera and Safari. Use the altKey, ctrlKey, metaKey and shiftKey properties instead.
Name Support Value
ALT_MASK
0x0001
CONTROL_MASK
0x0002
SHIFT_MASK
0x0004
META_MASK
0x0008

Properties:

Name Support Description
bubbles
Returns a Boolean value that indicates whether the current event can propagate up the DOM hierarchy or not.
cancelable
Returns a Boolean value that indicates whether the current event can be canceled or not.
cancelBubble
Sets or retrieves a Boolean value that indicates whether the current event should propagate up the DOM hierarchy, or not.
currentTarget
Returns a reference to the element whose event listener is being processed.
eventPhase
Returns an integer value that indicates the current processing phase of an event.
explicitOriginalTarget
Returns a reference to the exact object on which the event originally occurred.
isTrusted
Returns a Boolean value that indicates whether the event is a trusted event or not.
originalTarget
Returns a reference to the object on which the event originally occurred.
returnValue
Sets or retrieves a Boolean value that indicates whether the current event is canceled.
srcElement
Retrieves a reference to the object on which the event occurred.
target
Returns a reference to the object on which the event originally occurred.
timeStamp
Returns the time in milliseconds when the current event occurred.
type
Retrieves a string that represents the type of the event, such as "mouseout", "click", etc.

Methods:

Name Support Description
initEvent
Initializes an event object created by the createEvent method.
preventDefault
Cancels the current event.
stopPropagation
Disables the propagation of the current event in the DOM hierarchy.

Events represented by the Event interface:

Name Support Description
onafterprint
Occurs when the browser has built the contents of the current document for printing or for the print preview.
onbeforecopy
Occurs before the selection is copied to the clipboard and before the oncopy event.
onbeforecut
Occurs before the selection is cut from the document and provides a possibility to enable the Cut menu item.
onbeforepaste
Occurs before the contents of the clipboard are pasted into the document and provides a possibility to enable the Paste menu item.
onbeforeprint
Occurs when the browser starts to build the contents of the current document for printing or for the print preview.
onbeforeunload
Occurs before the browser unloads the document and provides a possibility to display a confirmation dialog, where the user can confirm whether he wants to stay or leave the current page.
onblur
Occurs when an element loses focus.
onbounce
Occurs when the contents of a marquee element touch one side of the marquee element's bounding rectangle.
onchange
Occurs when the selection, the checked state or the contents of an element have changed. In some cases, it only occurs when the element loses the focus.
CheckboxStateChange
Occurs when the state of a checkbox has changed.
oncopy
Occurs before the selection is copied to the clipboard.
oncut
Occurs before the selection is cut from the document and added to the clipboard.
onerror
Fires when an error occurs while loading an external file.
onfinish
Occurs when a marquee element has finished the scrolling animation.
onfocus
Occurs when an element receives focus.
onhashchange
3.610.65
Occurs when the hash subsection (begins with a '#' sign) of the current document's URL has changed.
onhelp
Occurs after the user has pressed the F1 key.
oninput
Occurs when the text content of an element is changed through the user interface.
onload
Occurs when an object has been loaded.
onoffline
3
Occurs when the browser starts to work offline.
ononline
3
Occurs when the browser starts to work online.
onpaste
Occurs before the contents of the clipboard are pasted into the document.
RadioStateChange
Occurs when the state of a radio button has changed.
onreadystatechange
Occurs when the load state of the data that belongs to an element or a HTML document changes.
onreadystatechange (XMLHttpRequest)
Occurs when the state of the request changes.
onreset
Occurs on a form before it is reset.
onresize
Occurs when the size of an object has changed.
onscroll
Occurs when the contents of an element have been scrolled.
onsearch
Occurs when the user presses the ENTER key or clicks the 'Erase search text' button (x) in an input:search field.
onselect
Occurs after some text has been selected in an element.
onselectionchange
Occurs when the selection in the document has changed.
onselectstart
Occurs at the start of a selection process.
onstart
Occurs when a marquee element begins the scrolling animation and when a new loop starts.
onstop
Occurs when the user aborts the loading of the document.
onsubmit
Occurs on a form element when the user clicks on a submit button in the form.
onunload
Occurs before the browser unloads the document.

Additional members of the DragEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Properties:

Name Support Description
dataTransfer
3.5
Represents a drag-and-drop operation.

Methods:

Name Support Description
initDragEvent
Initializes an event object created by the createEvent method with type of 'DragEvent'.

Events represented by the DragEvent interface:

Name Support Description
onbeforecopy
Occurs before the selection is copied to the clipboard and before the oncopy event.
onbeforecut
Occurs before the selection is cut from the document and provides a possibility to enable the Cut menu item.
onbeforepaste
Occurs before the contents of the clipboard are pasted into the document and provides a possibility to enable the Paste menu item.
oncopy
Occurs before the selection is copied to the clipboard.
oncut
Occurs before the selection is cut from the document and added to the clipboard.
ondrag
3.5
Occurs periodically on the source element during the drag operation.
ondragend
3.5
Occurs on the source element when the user has finished the drag operation.
ondragenter
3.5
Occurs on an element when the user moves the mouse pointer into it during a drag operation.
dragexit
3.5
Occurs on an element when the user moves the mouse pointer out of it during a drag operation.
draggesture
3.5
Occurs on the source element when the user starts the drag operation.
ondragleave
3.5
Occurs on an element when the user moves the mouse pointer out of it during a drag operation.
ondragover
3.5
Occurs periodically on an element while the mouse pointer is over it during a drag operation.
ondragstart
3.5
Occurs on the source element when the user starts the drag operation.
ondrop
3.5
Occurs on a possible target element when the dragged data is dropped on it.
onpaste
Occurs before the contents of the clipboard are pasted into the document.

Additional members of the KeyboardEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Constants:

The following constants are available in the scope of the KeyboardEvent interface (KeyboardEvent.DOM_VK_CANCEL). Using the constants instead of their numeric values results in more readable code.
The following constants represent Unicode key codes that can be used for the values of the keyCode and which properties and for the keyCode parameter of the initKeyEvent method.
Name Support Value
DOM_VK_CANCEL
3
DOM_VK_HELP
6
DOM_VK_BACK_SPACE
8
DOM_VK_TAB
9
DOM_VK_CLEAR
12
DOM_VK_RETURN
13
DOM_VK_ENTER
14
DOM_VK_SHIFT
16
DOM_VK_CONTROL
17
DOM_VK_ALT
18
DOM_VK_PAUSE
19
DOM_VK_CAPS_LOCK
20
DOM_VK_ESCAPE
27
DOM_VK_SPACE
32
DOM_VK_PAGE_UP
33
DOM_VK_PAGE_DOWN
34
DOM_VK_END
35
DOM_VK_HOME
36
DOM_VK_LEFT
37
DOM_VK_UP
38
DOM_VK_RIGHT
39
DOM_VK_DOWN
40
DOM_VK_PRINTSCREEN
44
DOM_VK_INSERT
45
DOM_VK_DELETE
46
DOM_VK_0
48
DOM_VK_1
49
DOM_VK_2
50
DOM_VK_3
51
DOM_VK_4
52
DOM_VK_5
53
DOM_VK_6
54
DOM_VK_7
55
DOM_VK_8
56
DOM_VK_9
57
DOM_VK_SEMICOLON
59
DOM_VK_EQUALS
61
DOM_VK_A
65
DOM_VK_B
66
DOM_VK_C
67
DOM_VK_D
68
DOM_VK_E
69
DOM_VK_F
70
DOM_VK_G
71
DOM_VK_H
72
DOM_VK_I
73
DOM_VK_J
74
DOM_VK_K
75
DOM_VK_L
76
DOM_VK_M
77
DOM_VK_N
78
DOM_VK_O
79
DOM_VK_P
80
DOM_VK_Q
81
DOM_VK_R
82
DOM_VK_S
83
DOM_VK_T
84
DOM_VK_U
85
DOM_VK_V
86
DOM_VK_W
87
DOM_VK_X
88
DOM_VK_Y
89
DOM_VK_Z
90
DOM_VK_CONTEXT_MENU
93
DOM_VK_NUMPAD0
96
DOM_VK_NUMPAD1
97
DOM_VK_NUMPAD2
98
DOM_VK_NUMPAD3
99
DOM_VK_NUMPAD4
100
DOM_VK_NUMPAD5
101
DOM_VK_NUMPAD6
102
DOM_VK_NUMPAD7
103
DOM_VK_NUMPAD8
104
DOM_VK_NUMPAD9
105
DOM_VK_MULTIPLY
106
DOM_VK_ADD
107
DOM_VK_SEPARATOR
108
DOM_VK_SUBTRACT
109
DOM_VK_DECIMAL
110
DOM_VK_DIVIDE
111
DOM_VK_F1
112
DOM_VK_F2
113
DOM_VK_F3
114
DOM_VK_F4
115
DOM_VK_F5
116
DOM_VK_F6
117
DOM_VK_F7
118
DOM_VK_F8
119
DOM_VK_F9
120
DOM_VK_F10
121
DOM_VK_F11
122
DOM_VK_F12
123
DOM_VK_F13
124
DOM_VK_F14
125
DOM_VK_F15
126
DOM_VK_F16
127
DOM_VK_F17
128
DOM_VK_F18
129
DOM_VK_F19
130
DOM_VK_F20
131
DOM_VK_F21
132
DOM_VK_F22
133
DOM_VK_F23
134
DOM_VK_F24
135
DOM_VK_NUM_LOCK
144
DOM_VK_SCROLL_LOCK
145
DOM_VK_COMMA
188
DOM_VK_PERIOD
190
DOM_VK_SLASH
191
DOM_VK_BACK_QUOTE
192
DOM_VK_OPEN_BRACKET
219
DOM_VK_BACK_SLASH
220
DOM_VK_CLOSE_BRACKET
221
DOM_VK_QUOTE
222
DOM_VK_META
224

Properties:

Name Support Description
altKey
Sets or retrieves a Boolean value that indicates whether the left or right ALT key was down at the time when the event occurred.
charCode
Retrieves the Unicode character code of the key that generated the onkeypress event.
ctrlKey
Sets or retrieves whether the left or right CTRL key was down at the time when the event occurred.
keyCode
Sets or retrieves the Unicode character code of the key that generated the onkeypress event and the Unicode key code of the key that generated the onkeydown and onkeyup events.
metaKey
Retrieves a Boolean value that indicates whether the META key was down at the time when the event occurred.
repeat
Sets or retrieves a Boolean value that indicates whether the onkeydown event is being repeated (a key has been down long enough).
shiftKey
Sets or retrieves a Boolean value that indicates whether the left or right SHIFT key was down at the time when the event occurred.
which
Returns the Unicode character or key code of the key or the identifier of the mouse button that was pressed when the current event fired.

Methods:

Name Support Description
initKeyEvent
Initializes an event object created by the createEvent method with type of 'KeyboardEvent'.

Events represented by the KeyboardEvent interface:

Name Support Description
onkeydown
Occurs on an element that has the focus when a key is pressed down and occurs periodically until the key is released.
onkeypress
Occurs on an element that has the focus when a key is pressed down and occurs periodically until the key is released.
onkeyup
Occurs on an element that has the focus when the user releases a key.

Additional members of the MessageEvent interface:

Browser support:
9310.6
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Properties:

Name Support Description
data
Returns the characters entered in case of the textInput event or the contents of the message for the onmessage event.
lastEventId
Returns the identifier of the last event in case of onmessage events.
origin
Returns the scheme, hostname and port of the document that caused the onmessage event.
source
Returns a reference to the window object that contains the document that caused the onmessage event.

Methods:

Name Support Description
initMessageEvent
Initializes an event object created by the createEvent method with type of 'MessageEvent'.

Events represented by the MessageEvent interface:

Name Support Description
onmessage
Occurs when the postMessage method sends a message to the current window.

Additional members of the MouseEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Properties:

Name Support Description
altKey
Sets or retrieves a Boolean value that indicates whether the left or right ALT key was down at the time when the event occurred.
button
Sets or retrieves the mouse button(s) that were pressed at the time when the current event was fired.
clientX
Sets or returns the x-coordinate of the mouse pointer relative to the top-left corner of the browser window's client area.
clientY
Sets or returns the y-coordinate of the mouse pointer relative to the top-left corner of the browser window's client area.
ctrlKey
Sets or retrieves whether the left or right CTRL key was down at the time when the event occurred.
dataTransfer
Represents a drag-and-drop operation.
fromElement
Returns a reference to the object that lost the active state or that the mouse pointer left.
layerX
Retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the closest positioned ancestor element of the element that fires the event.
layerY
Retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the closest positioned ancestor element of the element that fires the event.
metaKey
Retrieves a Boolean value that indicates whether the META key was down at the time when the event occurred.
offsetX
Sets or retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the offsetParent element of the element that fires the event.
offsetY
Sets or retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the offsetParent element of the element that fires the event.
pageX
Retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the document.
pageY
Retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the document.
relatedTarget
Returns a reference to the related element in case of onmouseover, onmouseout, dragenter and dragexit events.
screenX
Sets or retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the screen.
screenY
Sets or retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the screen.
shiftKey
Sets or retrieves a Boolean value that indicates whether the left or right SHIFT key was down at the time when the event occurred.
toElement
Returns a reference to the object that the mouse pointer entered.
which
Returns the Unicode character or key code of the key or the identifier of the mouse button that was pressed when the current event fired.
x
Sets or retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the closest relatively positioned ancestor element of the element that fires the event.
y
Sets or retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the closest relatively positioned ancestor element of the element that fires the event.

Methods:

Name Support Description
initMouseEvent
Initializes an event object created by the createEvent method with type of 'MouseEvent'.

Events represented by the MouseEvent interface:

Name Support Description
onclick
Occurs when the user clicks on an element.
oncontextmenu
Occurs when the right mouse button is clicked on an element and the context menu is shown.
ondblclick
Occurs when the user double clicks on an element.
DOMMouseScroll
3.5
Occurs when the mouse wheel rolls.
ondrag
3
3.5
Occurs periodically on the source element during the drag operation.
dragdrop
3.5
Occurs on a possible target element when the dragged data is dropped on it.
ondragend
3
3.5
Occurs on the source element when the user has finished the drag operation.
ondragenter
3.5
Occurs on an element when the user moves the mouse pointer into it during a drag operation.
dragexit
3.5
Occurs on an element when the user moves the mouse pointer out of it during a drag operation.
draggesture
3.5
Occurs on the source element when the user starts the drag operation.
ondragleave
Occurs on an element when the user moves the mouse pointer out of it during a drag operation.
ondragover
3.5
Occurs periodically on an element while the mouse pointer is over it during a drag operation.
ondragstart
Occurs on the source element when the user starts the drag operation.
ondrop
Occurs on a possible target element when the dragged data is dropped on it.
onmousedown
Occurs when the user presses a mouse button over an element.
onmouseenter
Occurs when the user moves the mouse pointer into the area of an element.
onmouseleave
Occurs when the user moves the mouse pointer out of the element.
onmousemove
Occurs when the user moves the mouse over the element.
onmouseout
Occurs when the user moves the mouse pointer out of the element.
onmouseover
Occurs when the user moves the mouse pointer into the element.
onmouseup
Occurs when the user releases a mouse button over an element.

Additional members of the MutationEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Constants:

The following constants are available in the scope of the MutationEvent interface (MutationEvent.MODIFICATION). Using the constants instead of their numeric values results in more readable code.
The following constants represent actions that can be used for the value of the attrChange property and for the attrChange parameter of the initMutationEvent method.
Name Support Value Description
MODIFICATION
1 Modification action occurred.
ADDITION
2 Addition action occurred.
REMOVAL
3 Removal action occurred.

Properties:

Name Support Description
attrChange
Returns an integer that specifies the type of the action that modified an attribute.
attrName
Retrieves a string that specifies the name of the modified attribute.
newValue
Retrieves a string that specifies the current value of the modified attribute or TextNode element.
prevValue
Retrieves a string that specifies the previous value of the modified attribute or TextNode element.
relatedNode
Returns a reference to the node on which the mutation event occurred.

Methods:

Name Support Description
initMutationEvent
Initializes an event object created by the createEvent method with type of 'MutationEvent'.

Events represented by the MutationEvent interface:

Name Support Description
DOMAttrModified
Fires when an attribute is added, removed or when the value of an attribute is modified by script.
DOMCharacterDataModified
Fires when a script changes the value of a TextNode.
DOMNodeInserted
Occurs on a node when it is added to an element.
DOMNodeInsertedIntoDocument
Occurs on a node when it is inserted into the document.
DOMNodeRemoved
Occurs on a node when it is removed from its parent.
DOMNodeRemovedFromDocument
Occurs on a node when it is removed from the document.
DOMSubtreeModified
Fires on a node when a modification occurs in the subtree that belongs to it.

Additional members of the OverflowEvent interface:

Browser support:
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Constants:

The following constants are available in the scope of the OverflowEvent interface (OverflowEvent.HORIZONTAL). Using the constants instead of their numeric values results in more readable code.
The following constants identify scrollbars that can be used for the value of the orient property and for the orient parameter of the initOverflowEvent method.
Name Support Value Description
HORIZONTAL
0 Identifies the horizontal scrollbar.
VERTICAL
1 Identifies the vertical scrollbar.
BOTH
2 Identifies both the horizontal and vertical scrollbars.

Properties:

Name Support Description
horizontalOverflow
Retrieves a Boolean value that indicates the horizontal overflow state of an element when the overflowchanged event occurred.
orient
Retrieves whether the visibility of the horizontal or vertical scrollbar changed when the overflowchanged event occurred.
verticalOverflow
Retrieves a Boolean value that indicates the vertical overflow state of an element when the overflowchanged event occurred.

Methods:

Name Support Description
initOverflowEvent
Initializes an event object created by the createEvent method with type of 'OverflowEvent'.

Events represented by the OverflowEvent interface:

Name Support Description
overflowchanged
Occurs when the contents or the size of an element is changed and it causes a scrollbar to appear or disappear.

Additional members of the TextEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Properties:

Name Support Description
data
Returns the characters entered in case of the textInput event or the contents of the message for the onmessage event.

Methods:

Name Support Description
initTextEvent
Initializes an event object created by the createEvent method with type of 'TextEvent'.

Events represented by the TextEvent interface:

Name Support Description
textInput
Occurs when some characters are entered into an element.

Additional members of the UIEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy. If you need an object that implements this interface, see the page for the event object.

Properties:

Name Support Description
cancelBubble
Sets or retrieves a Boolean value that indicates whether the current event should propagate up the DOM hierarchy, or not.
charCode
Retrieves the Unicode character code of the key that generated the onkeypress event.
detail
Returns an integer value that specifies additional information about the event.
isChar
Returns whether the character that belongs to the current event is a key character or not.
keyCode
Sets or retrieves the Unicode character code of the key that generated the onkeypress event and the Unicode key code of the key that generated the onkeydown and onkeyup events.
layerX
Retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the closest positioned ancestor element of the element that fires the event.
layerY
Retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the closest positioned ancestor element of the element that fires the event.
pageX
Retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the document.
pageY
Retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the document.
rangeOffset
Returns the end position of the current selection relative to the element referred to by the rangeParent.
rangeParent
Returns a reference to the element where the selection ends.
view
Returns a reference to the AbstractView object where the event occurred.
which
Returns the Unicode character or key code of the key or the identifier of the mouse button that was pressed when the current event fired.

Methods:

Name Support Description
getPreventDefault
Returns whether the default action of the current event is canceled or not.
initUIEvent
Initializes an event object created by the createEvent method with type of 'UIEvent'.

Events represented by the UIEvent interface:

Name Support Description
onabort
Occurs when the user aborts the loading of an img or input:image element.
onactivate
Occurs when an element becomes active.
onbeforeactivate
Occurs before an element becomes active.
onbeforedeactivate
Occurs on the active element before it loses the active state.
ondeactivate
Occurs on the active element when it loses the active state.
DOMActivate
Occurs when an element becomes active.
DOMFocusIn
Occurs before an element receives focus.
DOMFocusOut
Occurs before an element loses the focus.
overflow
Occurs when the contents or the size of an element is changed and it causes a scrollbar to appear.
onresize
Occurs when the size of an object has changed.
onscroll
Occurs when the contents of an element have been scrolled.
onselect
Occurs after some text has been selected in an element.
underflow
Occurs when the contents or the size of an element is changed and it causes a scrollbar to disappear.

Additional members of the WheelEvent interface:

Browser support:
9
Click here to see this interface in the inheritance hierarchy.
Note: The WheelEvent interface inherits from the UIEvent interface in Google Chrome and Safari.
If you need an object that implements this interface, see the page for the event object.

Properties:

Name Support Description
altKey
Sets or retrieves a Boolean value that indicates whether the left or right ALT key was down at the time when the event occurred.
clientX
Sets or returns the x-coordinate of the mouse pointer relative to the top-left corner of the browser window's client area.
clientY
Sets or returns the y-coordinate of the mouse pointer relative to the top-left corner of the browser window's client area.
ctrlKey
Sets or retrieves whether the left or right CTRL key was down at the time when the event occurred.
metaKey
Retrieves a Boolean value that indicates whether the META key was down at the time when the event occurred.
offsetX
Sets or retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the offsetParent element of the element that fires the event.
offsetY
Sets or retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the offsetParent element of the element that fires the event.
screenX
Sets or retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the screen.
screenY
Sets or retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the screen.
shiftKey
Sets or retrieves a Boolean value that indicates whether the left or right SHIFT key was down at the time when the event occurred.
wheelDelta
Returns an integer value indicating the distance that the mouse wheel rolled.
x
Sets or retrieves the x-coordinate of the mouse pointer relative to the top-left corner of the closest relatively positioned ancestor element of the element that fires the event.
y
Sets or retrieves the y-coordinate of the mouse pointer relative to the top-left corner of the closest relatively positioned ancestor element of the element that fires the event.

Events represented by the WheelEvent interface:

Name Support Description
onmousewheel
Occurs when the mouse wheel rolls.

Examples:

This example shows how to add a method to the HTMLAnchorElement interface so this method can be used on all anchor elements:
<head>
    <script type="text/javascript">
        if (typeof HTMLAnchorElement != "undefined") {
            HTMLAnchorElement.prototype.GetHref = function () {
                alert (this.href);
            };
        }
        else {
            alert ("Your browser doesn't support this example!");
        }

        function GetAnchorHref () {
            var anchor = document.getElementById ("myAnchor");
            anchor.GetHref ();
        }
    </script>
</head>
<body>
    <a id="myAnchor" href="http://help.dottoro.com">an anchor element</a>
    <button onclick="GetAnchorHref ();">Get the href attribute of the anchor</button>
</body>
Did you find this example helpful? yes no
This example shows how to add a method to the HTMLElement interface so this method can be used on all elements:
<head>
    <script type="text/javascript">
        if (typeof HTMLElement != "undefined") {
            HTMLElement.prototype.GetTextContent = function () {
                var cont = (this.innerText != undefined)? this.innerText : this.textContent;
                alert (cont);
            };
        }
        else {
            alert ("Your browser doesn't support this example!");
        }

        function GetAnchorHref (button) {
            var anchor = document.getElementById ("myAnchor");
            anchor.GetTextContent ();
            button.GetTextContent ();
        }
    </script>
</head>
<body>
    <a id="myAnchor">an anchor element</a>
    <button onclick="GetAnchorHref (this);">Get the text content of the anchor and this button</button>
</body>
Did you find this example helpful? yes no
User Contributed Comments

Post Content

Post Content