Appendix C: ECMA Script Language Binding
This appendix contains the complete ECMA Script [ECMAScript] binding for the Level 2 Document Object Model Events
definitions.
Note:
Exceptions handling is only supported by ECMAScript implementation
compliant with the Standard ECMA-262 3rd. Edition ([ECMAScript]).
- Object EventTarget
-
- The EventTarget object has the following methods:
- addEventListener(type, listener, useCapture)
- This method has no return value.
The type parameter is of type String.
The listener parameter is of type EventListener.
The useCapture parameter is of type boolean.
- removeEventListener(type, listener, useCapture)
- This method has no return value.
The type parameter is of type String.
The listener parameter is of type EventListener.
The useCapture parameter is of type boolean.
- dispatchEvent(evt)
- This method returns a boolean.
The evt parameter is of type Event.
This method can raise a EventException.
- Object EventListener
- This is an ECMAScript function reference. This method returns a void. The parameter is of type Event.
- Class Event
-
- The Event class has the following constants:
- Event.CAPTURING_PHASE
-
This constant is of type short and its value is 1.
- Event.AT_TARGET
-
This constant is of type short and its value is 2.
- Event.BUBBLING_PHASE
-
This constant is of type short and its value is 3.
- Object Event
-
- The Event object has the following properties:
- type
-
This read-only property is of type String.
- target
-
This read-only property is of type EventTarget.
- currentTarget
-
This read-only property is of type EventTarget.
- eventPhase
-
This read-only property is of type short.
- bubbles
-
This read-only property is of type boolean.
- cancelable
-
This read-only property is of type boolean.
- timeStamp
-
This read-only property is of type Date.
- The Event object has the following methods:
- stopPropagation()
- This method has no return value.
- preventDefault()
- This method has no return value.
- initEvent(eventTypeArg, canBubbleArg, cancelableArg)
- This method has no return value.
The eventTypeArg parameter is of type String.
The canBubbleArg parameter is of type boolean.
The cancelableArg parameter is of type boolean.
- Class EventException
-
- The EventException class has the following constants:
- EventException.UNSPECIFIED_EVENT_TYPE_ERR
-
This constant is of type short and its value is 0.
- Exception EventException
-
- The EventException object has the following properties:
- code
-
This property is of type unsigned short.
- Object DocumentEvent
-
- The DocumentEvent object has the following methods:
- createEvent(eventType)
- This method returns a Event.
The eventType parameter is of type String.
This method can raise a DOMException.
- Object UIEvent
-
- UIEvent has the all the properties and methods of Event as well as the properties and methods defined below.
- The UIEvent object has the following properties:
- view
-
This read-only property is of type AbstractView.
- detail
-
This read-only property is of type long.
- The UIEvent object has the following methods:
- initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg)
- This method has no return value.
The typeArg parameter is of type String.
The canBubbleArg parameter is of type boolean.
The cancelableArg parameter is of type boolean.
The viewArg parameter is of type AbstractView.
The detailArg parameter is of type long.
- Object MouseEvent
-
- MouseEvent has the all the properties and methods of UIEvent as well as the properties and methods defined below.
- The MouseEvent object has the following properties:
- screenX
-
This read-only property is of type long.
- screenY
-
This read-only property is of type long.
- clientX
-
This read-only property is of type long.
- clientY
-
This read-only property is of type long.
- ctrlKey
-
This read-only property is of type boolean.
- shiftKey
-
This read-only property is of type boolean.
- altKey
-
This read-only property is of type boolean.
- metaKey
-
This read-only property is of type boolean.
- button
-
This read-only property is of type short.
- relatedTarget
-
This read-only property is of type EventTarget.
- The MouseEvent object has the following methods:
- initMouseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg)
- This method has no return value.
The typeArg parameter is of type String.
The canBubbleArg parameter is of type boolean.
The cancelableArg parameter is of type boolean.
The viewArg parameter is of type AbstractView.
The detailArg parameter is of type long.
The screenXArg parameter is of type long.
The screenYArg parameter is of type long.
The clientXArg parameter is of type long.
The clientYArg parameter is of type long.
The ctrlKeyArg parameter is of type boolean.
The altKeyArg parameter is of type boolean.
The shiftKeyArg parameter is of type boolean.
The metaKeyArg parameter is of type boolean.
The buttonArg parameter is of type short.
The relatedTargetArg parameter is of type EventTarget.
- Class MutationEvent
-
- The MutationEvent class has the following constants:
- MutationEvent.MODIFICATION
-
This constant is of type short and its value is 1.
- MutationEvent.ADDITION
-
This constant is of type short and its value is 2.
- MutationEvent.REMOVAL
-
This constant is of type short and its value is 3.
- Object MutationEvent
-
- MutationEvent has the all the properties and methods of Event as well as the properties and methods defined below.
- The MutationEvent object has the following properties:
- relatedNode
-
This read-only property is of type Node.
- prevValue
-
This read-only property is of type String.
- newValue
-
This read-only property is of type String.
- attrName
-
This read-only property is of type String.
- attrChange
-
This read-only property is of type short.
- The MutationEvent object has the following methods:
- initMutationEvent(typeArg, canBubbleArg, cancelableArg, relatedNodeArg, prevValueArg, newValueArg, attrNameArg)
- This method has no return value.
The typeArg parameter is of type String.
The canBubbleArg parameter is of type boolean.
The cancelableArg parameter is of type boolean.
The relatedNodeArg parameter is of type Node.
The prevValueArg parameter is of type String.
The newValueArg parameter is of type String.
The attrNameArg parameter is of type String.
The following example will add an ECMA Script based EventListener to the
Node 'exampleNode':
// Given the Node 'exampleNode'
// Define the EventListener function
function clickHandler(evt)
{
// Function contents
}
// The following line will add a non-capturing 'click' listener
// to 'exampleNode'.
exampleNode.addEventListener("click", clickHandler, false);