ECMAScript Language Binding

13 November, 2000

# Appendix C: ECMAScript Language Binding

This appendix contains the complete ECMAScript [ECMAScript] binding for the Level 2 Document Object Model Events definitions.

Note: Exceptions handling is only supported by ECMAScript implementation conformant 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 a EventListener object.
      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 a EventListener object.
      The useCapture parameter is of type Boolean.
    dispatchEvent(evt)
      This method returns a Boolean.
      The evt parameter is a Event object.
      This method can raise a EventException object.
Object EventListener
  This is an ECMAScript function reference. This method has no return value. The parameter is a Event object.
Prototype Object Event
  The Event class has the following constants:
    Event.CAPTURING_PHASE
      This constant is of type Number and its value is 1.
    Event.AT_TARGET
      This constant is of type Number and its value is 2.
    Event.BUBBLING_PHASE
      This constant is of type Number 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 a EventTarget object.
    currentTarget
      This read-only property is a EventTarget object.
    eventPhase
      This read-only property is of type Number.
    bubbles
      This read-only property is of type Boolean.
    cancelable
      This read-only property is of type Boolean.
    timeStamp
      This read-only property is a Date object.
  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.
Prototype Object EventException
  The EventException class has the following constants:
    EventException.UNSPECIFIED_EVENT_TYPE_ERR
      This constant is of type Number and its value is 0.
Object EventException
  The EventException object has the following properties:
    code
      This property is of type Number.
Object DocumentEvent
  The DocumentEvent object has the following methods:
    createEvent(eventType)
      This method returns a Event object.
      The eventType parameter is of type String.
      This method can raise a DOMException object.
Object UIEvent
  UIEvent has the all the properties and methods of the Event object as well as the properties and methods defined below.
  The UIEvent object has the following properties:
    view
      This read-only property is a AbstractView object.
    detail
      This read-only property is a long object.
  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 a AbstractView object.
      The detailArg parameter is a long object.
Object MouseEvent
  MouseEvent has the all the properties and methods of the UIEvent object as well as the properties and methods defined below.
  The MouseEvent object has the following properties:
    screenX
      This read-only property is a long object.
    screenY
      This read-only property is a long object.
    clientX
      This read-only property is a long object.
    clientY
      This read-only property is a long object.
    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 Number.
    relatedTarget
      This read-only property is a EventTarget object.
  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 a AbstractView object.
      The detailArg parameter is a long object.
      The screenXArg parameter is a long object.
      The screenYArg parameter is a long object.
      The clientXArg parameter is a long object.
      The clientYArg parameter is a long object.
      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 Number.
      The relatedTargetArg parameter is a EventTarget object.
Prototype Object MutationEvent
  The MutationEvent class has the following constants:
    MutationEvent.MODIFICATION
      This constant is of type Number and its value is 1.
    MutationEvent.ADDITION
      This constant is of type Number and its value is 2.
    MutationEvent.REMOVAL
      This constant is of type Number and its value is 3.
Object MutationEvent
  MutationEvent has the all the properties and methods of the Event object as well as the properties and methods defined below.
  The MutationEvent object has the following properties:
    relatedNode
      This read-only property is a Node object.
    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 Number.
  The MutationEvent object has the following methods:
    initMutationEvent(typeArg, canBubbleArg, cancelableArg, relatedNodeArg, prevValueArg, newValueArg, attrNameArg, attrChangeArg)
      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 a Node object.
      The prevValueArg parameter is of type String.
      The newValueArg parameter is of type String.
      The attrNameArg parameter is of type String.
      The attrChangeArg parameter is of type Number.

The following example will add an ECMAScript 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);