You are here: Reference > appendix > javascript > interfaces
Interfaces in JavaScript
AA
Font size
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
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.
Firefox supports the ProgressEvent interface from version 3.5.
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 'SVGZoomEvent' type to create and the initUIEvent 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
Description
CAPTURING_PHASE
The event flow is in capturing phase.
AT_TARGET
The event flow is in target phase.
BUBBLING_PHASE
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
ABORT
BACK
BLUR
CLICK
CHANGE
DBLCLICK
DRAGDROP
ERROR
FOCUS
FORWARD
HELP
KEYDOWN
KEYPRESS
KEYUP
LOAD
LOCATE
MOUSEDOWN
MOUSEDRAG
MOUSEMOVE
MOUSEOUT
MOUSEOVER
MOUSEUP
MOVE
RESET
RESIZE
SCROLL
SELECT
SUBMIT
UNLOAD
XFER_DONE
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, Opera and Safari.
Use the altKey, ctrlKey, metaKey and shiftKey properties instead.
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.
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.
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.
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.
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
Description
HORIZONTAL
Identifies the horizontal scrollbar.
VERTICAL
Identifies the vertical scrollbar.
BOTH
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.
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.
Examples:
This example shows how to add a method to the HTMLAnchorElement interface so this method can be used on all anchor elements:
<head><scripttype="text/javascript">if (typeofHTMLAnchorElement != "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><aid="myAnchor"href="www.dottoro.com">an anchor element</a><buttononclick="GetAnchorHref ();">Get the href attribute of the anchor</button></body>
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>