<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Generated: Thu Nov 09 17:44:26 EST 2000 jfouffa.w3.org --> <html lang='en' xmlns="http://www.w3.org/1999/xhtml"> <head> <title>ECMAScript Language Binding</title> <link rel='stylesheet' type='text/css' href='./spec.css' /> <link rel='stylesheet' type='text/css' href='W3C-REC.css' /> <link rel='next' href='acknowledgements.html' /> <link rel='contents' href='Overview.html#contents' /> <link rel='index' href='def-index.html' /> <link rel='previous' href='java-binding.html' /> </head> <body> <div class='navbar' align='center'><a accesskey='p' href='java-binding.html'>previous</a> <a accesskey='n' href='acknowledgements.html'>next</a> <a accesskey='c' href='Overview.html#contents'>contents</a> <a accesskey='i' href='def-index.html'>index</a> <hr title='Navigation area separator' /> </div> <div class='noprint' style='text-align: right'> <p style='font-family: monospace;font-size:small'>13 November, 2000</p> </div> <div class='div1'><a id="ecma-binding" name='ecma-binding'></a> <h1 id='ecma-binding-h1' class='adiv1'>Appendix C: ECMAScript Language Binding</h1> <p>This appendix contains the complete ECMAScript [<a class='noxref' href='references.html#ECMAScript'>ECMAScript</a>] binding for the Level 2 Document Object Model Events definitions.</p> <p><b>Note:</b> Exceptions handling is only supported by ECMAScript implementation conformant with the Standard ECMA-262 3rd. Edition ([<a class='noxref' href='references.html#ECMAScript'>ECMAScript</a>]).</p> <div class='ecma-block'> <dl> <dt>Object <b>EventTarget</b></dt> <dd> <dl> <dt>The <b>EventTarget</b> object has the following methods:</dt> <dd> <dl> <dt><b>addEventListener(type, listener, useCapture)</b></dt> <dd>This method has no return value.<br /> The <b>type</b> parameter is of type <b>String</b>.<br /> The <b>listener</b> parameter is a <b>EventListener</b> object.<br /> The <b>useCapture</b> parameter is of type <b>Boolean</b>.</dd> <dt><b>removeEventListener(type, listener, useCapture)</b></dt> <dd>This method has no return value.<br /> The <b>type</b> parameter is of type <b>String</b>.<br /> The <b>listener</b> parameter is a <b>EventListener</b> object.<br /> The <b>useCapture</b> parameter is of type <b>Boolean</b>.</dd> <dt><b>dispatchEvent(evt)</b></dt> <dd>This method returns a <b>Boolean</b>.<br /> The <b>evt</b> parameter is a <b>Event</b> object.<br /> This method can raise a <b>EventException</b> object.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>EventListener</b></dt> <dd>This is an ECMAScript function reference. This method has no return value. The parameter is a <b>Event</b> object.</dd> <dt>Prototype Object <b>Event</b></dt> <dd> <dl> <dt>The <b>Event</b> class has the following constants:</dt> <dd> <dl> <dt><b>Event.CAPTURING_PHASE</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>1</b>.</dd> <dt><b>Event.AT_TARGET</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>2</b>.</dd> <dt><b>Event.BUBBLING_PHASE</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>3</b>.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>Event</b></dt> <dd> <dl> <dt>The <b>Event</b> object has the following properties:</dt> <dd> <dl> <dt><b>type</b></dt> <dd>This read-only property is of type <b>String</b>.</dd> <dt><b>target</b></dt> <dd>This read-only property is a <b>EventTarget</b> object.</dd> <dt><b>currentTarget</b></dt> <dd>This read-only property is a <b>EventTarget</b> object.</dd> <dt><b>eventPhase</b></dt> <dd>This read-only property is of type <b>Number</b>.</dd> <dt><b>bubbles</b></dt> <dd>This read-only property is of type <b>Boolean</b>.</dd> <dt><b>cancelable</b></dt> <dd>This read-only property is of type <b>Boolean</b>.</dd> <dt><b>timeStamp</b></dt> <dd>This read-only property is a <b>Date</b> object.</dd> </dl> </dd> <dt>The <b>Event</b> object has the following methods:</dt> <dd> <dl> <dt><b>stopPropagation()</b></dt> <dd>This method has no return value.</dd> <dt><b>preventDefault()</b></dt> <dd>This method has no return value.</dd> <dt><b>initEvent(eventTypeArg, canBubbleArg, cancelableArg)</b></dt> <dd>This method has no return value.<br /> The <b>eventTypeArg</b> parameter is of type <b>String</b>.<br /> The <b>canBubbleArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>cancelableArg</b> parameter is of type <b>Boolean</b>.</dd> </dl> </dd> </dl> </dd> <dt>Prototype Object <b>EventException</b></dt> <dd> <dl> <dt>The <b>EventException</b> class has the following constants:</dt> <dd> <dl> <dt><b>EventException.UNSPECIFIED_EVENT_TYPE_ERR</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>0</b>.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>EventException</b></dt> <dd> <dl> <dt>The <b>EventException</b> object has the following properties:</dt> <dd> <dl> <dt><b>code</b></dt> <dd>This property is of type <b>Number</b>.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>DocumentEvent</b></dt> <dd> <dl> <dt>The <b>DocumentEvent</b> object has the following methods:</dt> <dd> <dl> <dt><b>createEvent(eventType)</b></dt> <dd>This method returns a <b>Event</b> object.<br /> The <b>eventType</b> parameter is of type <b>String</b>.<br /> This method can raise a <b>DOMException</b> object.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>UIEvent</b></dt> <dd> <dl> <dt><b>UIEvent</b> has the all the properties and methods of the <b>Event</b> object as well as the properties and methods defined below.</dt> <dt>The <b>UIEvent</b> object has the following properties:</dt> <dd> <dl> <dt><b>view</b></dt> <dd>This read-only property is a <b>AbstractView</b> object.</dd> <dt><b>detail</b></dt> <dd>This read-only property is a <b>long</b> object.</dd> </dl> </dd> <dt>The <b>UIEvent</b> object has the following methods:</dt> <dd> <dl> <dt><b>initUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg)</b></dt> <dd>This method has no return value.<br /> The <b>typeArg</b> parameter is of type <b>String</b>.<br /> The <b>canBubbleArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>cancelableArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>viewArg</b> parameter is a <b>AbstractView</b> object.<br /> The <b>detailArg</b> parameter is a <b>long</b> object.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>MouseEvent</b></dt> <dd> <dl> <dt><b>MouseEvent</b> has the all the properties and methods of the <b>UIEvent</b> object as well as the properties and methods defined below.</dt> <dt>The <b>MouseEvent</b> object has the following properties:</dt> <dd> <dl> <dt><b>screenX</b></dt> <dd>This read-only property is a <b>long</b> object.</dd> <dt><b>screenY</b></dt> <dd>This read-only property is a <b>long</b> object.</dd> <dt><b>clientX</b></dt> <dd>This read-only property is a <b>long</b> object.</dd> <dt><b>clientY</b></dt> <dd>This read-only property is a <b>long</b> object.</dd> <dt><b>ctrlKey</b></dt> <dd>This read-only property is of type <b>Boolean</b>.</dd> <dt><b>shiftKey</b></dt> <dd>This read-only property is of type <b>Boolean</b>.</dd> <dt><b>altKey</b></dt> <dd>This read-only property is of type <b>Boolean</b>.</dd> <dt><b>metaKey</b></dt> <dd>This read-only property is of type <b>Boolean</b>.</dd> <dt><b>button</b></dt> <dd>This read-only property is of type <b>Number</b>.</dd> <dt><b>relatedTarget</b></dt> <dd>This read-only property is a <b>EventTarget</b> object.</dd> </dl> </dd> <dt>The <b>MouseEvent</b> object has the following methods:</dt> <dd> <dl> <dt><b>initMouseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg)</b></dt> <dd>This method has no return value.<br /> The <b>typeArg</b> parameter is of type <b>String</b>.<br /> The <b>canBubbleArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>cancelableArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>viewArg</b> parameter is a <b>AbstractView</b> object.<br /> The <b>detailArg</b> parameter is a <b>long</b> object.<br /> The <b>screenXArg</b> parameter is a <b>long</b> object.<br /> The <b>screenYArg</b> parameter is a <b>long</b> object.<br /> The <b>clientXArg</b> parameter is a <b>long</b> object.<br /> The <b>clientYArg</b> parameter is a <b>long</b> object.<br /> The <b>ctrlKeyArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>altKeyArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>shiftKeyArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>metaKeyArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>buttonArg</b> parameter is of type <b>Number</b>.<br /> The <b>relatedTargetArg</b> parameter is a <b>EventTarget</b> object.</dd> </dl> </dd> </dl> </dd> <dt>Prototype Object <b>MutationEvent</b></dt> <dd> <dl> <dt>The <b>MutationEvent</b> class has the following constants:</dt> <dd> <dl> <dt><b>MutationEvent.MODIFICATION</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>1</b>.</dd> <dt><b>MutationEvent.ADDITION</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>2</b>.</dd> <dt><b>MutationEvent.REMOVAL</b></dt> <dd>This constant is of type <b>Number</b> and its value is <b>3</b>.</dd> </dl> </dd> </dl> </dd> <dt>Object <b>MutationEvent</b></dt> <dd> <dl> <dt><b>MutationEvent</b> has the all the properties and methods of the <b>Event</b> object as well as the properties and methods defined below.</dt> <dt>The <b>MutationEvent</b> object has the following properties:</dt> <dd> <dl> <dt><b>relatedNode</b></dt> <dd>This read-only property is a <b>Node</b> object.</dd> <dt><b>prevValue</b></dt> <dd>This read-only property is of type <b>String</b>.</dd> <dt><b>newValue</b></dt> <dd>This read-only property is of type <b>String</b>.</dd> <dt><b>attrName</b></dt> <dd>This read-only property is of type <b>String</b>.</dd> <dt><b>attrChange</b></dt> <dd>This read-only property is of type <b>Number</b>.</dd> </dl> </dd> <dt>The <b>MutationEvent</b> object has the following methods:</dt> <dd> <dl> <dt><b>initMutationEvent(typeArg, canBubbleArg, cancelableArg, relatedNodeArg, prevValueArg, newValueArg, attrNameArg, attrChangeArg)</b></dt> <dd>This method has no return value.<br /> The <b>typeArg</b> parameter is of type <b>String</b>.<br /> The <b>canBubbleArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>cancelableArg</b> parameter is of type <b>Boolean</b>.<br /> The <b>relatedNodeArg</b> parameter is a <b>Node</b> object.<br /> The <b>prevValueArg</b> parameter is of type <b>String</b>.<br /> The <b>newValueArg</b> parameter is of type <b>String</b>.<br /> The <b>attrNameArg</b> parameter is of type <b>String</b>.<br /> The <b>attrChangeArg</b> parameter is of type <b>Number</b>.</dd> </dl> </dd> </dl> </dd> </dl> </div> <!-- ecma-block --> <p>The following example will add an ECMAScript based EventListener to the Node 'exampleNode':</p> <div class='code-block'> <pre> // 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); </pre> </div> </div> <!-- div1 ecma-binding --> <div class='navbar' align='center'> <hr title='Navigation area separator' /> <a accesskey='p' href='java-binding.html'>previous</a> <a accesskey='n' href='acknowledgements.html'>next</a> <a accesskey='c' href='Overview.html#contents'>contents</a> <a accesskey='i' href='def-index.html'>index</a></div> </body> </html>