Cookies improve the way our website works, by using this website you are agreeing to our use of cookies. For more information see our privacy policy.
OK
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.
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.
event
Use the createEvent method with 'CustomEvent' type to create and the initCustomEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'MessageEvent' type to create and the initMessageEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'MutationEvent' type to create and the initMutationEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'OverflowEvent' type to create and the initOverflowEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'PopupBlockedEvents' type to create and the initPopupBlockedEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'ProgressEvent' type to create and the initProgressEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'StorageEvent' type to create and the initStorageEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'UIEvent' type to create and the initUIEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'CompositionEvent' type to create and the initCompositionEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'FocusEvent' type to create and the initFocusEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'KeyboardEvent' type to create and the initKeyEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'MouseEvent' type to create and the initMouseEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'DragEvent' type to create and the initDragEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'MouseScrollEvent' type to create and the initMouseScrollEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'MouseWheelEvent' type to create and the initMouseWheelEvent method to initialize an event object that implements this interface.
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.
event
Use the createEvent method with 'SVGZoomEvent' type to create and the initUIEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'TextEvent' type to create and the initTextEvent method to initialize an event object that implements this interface.
event
Use the createEvent method with 'XULCommandEvent' type to create and the initCommandEvent method to initialize an event object that implements this interface.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
This example shows how to add a method to the HTMLElement interface so this method can be used on all elements:
<head><scripttype="text/javascript">if (typeofHTMLElement != "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><aid="myAnchor">an anchor element</a><buttononclick="GetAnchorHref (this);">Get the text content of the anchor and this button</button></body>