Package | dom.events |
Interface | public interface EventTarget |
Implementors | Node, Window |
Introduced in: | DOM 2 Events |
When used with the DOM event flow, this interface is implemented by all target nodes and target ancestors, i.e. all DOM Nodes of the tree support this interface when the implementation conforms to DOM Level 3 Events and, therefore, this interface can be obtained by using binding-specific casting methods on an instance of the Node interface.
Invoking addEventListener or addEventListenerNS repeatedly on the same EventTarget with the same values for the parameters namespaceURI, type, listener, and useCapture has no effect. Doing so does not cause the EventListener to be called more than once and does not cause a change in the triggering order.
See also
Method | Defined By | ||
---|---|---|---|
Associates a function with a particular event and binds the event to the current node. | EventTarget | ||
DOM 3 Events addEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Registers an event listener, depending on the useCapture parameter, on the
capture phase of the DOM event flow or its target and bubbling phases. | EventTarget | ||
Dispatches an event to fire on a node artificially. | EventTarget | ||
Removes an event listener. | EventTarget | ||
DOM 3 Events removeEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Removes an event listener. | EventTarget |
DOM 2 Events addEventListener | () | method |
public function addEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void
Introduced in: | DOM 2 Events |
Associates a function with a particular event and binds the event to the current node.
Parameters
type:DOMString — A string representing the event to bind, without the "on" prefix. For example, "click", "mousedown" etc.
| |
listener:EventListener — The function or method to associate with the event.
| |
useCapture:Boolean — Whether to bind the event as it is propagating towards the target node, (event Capture), or as the
event bubbles upwards from the target (event bubble). Set to true or false, respectively.
|
See also
function statusreport() { alert("document has loaded"); } if (window.addEventListener) { window.addEventListener("load", statusreport, false); //invoke function } window.onload = statusreport(); //function invoked again, since no event handler conflicts
DOM 3 Events addEventListenerNS | () | method |
public function addEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Introduced in: | DOM 3 Events |
Registers an event listener, depending on the useCapture parameter, on the capture phase of the DOM event flow or its target and bubbling phases.
Parameters
namespaceURI:DOMString — Specifies the Event.namespaceURI associated with the event for which the user is registering.
| |
type:DOMString — A string representing the event to bind, without the "on" prefix. For example, "click", "mousedown" etc.
| |
listener:EventListener — The function or method to associate with the event.
| |
useCapture:Boolean — Whether to bind the event as it is propagating towards the target node, (event Capture), or as the
event bubbles upwards from the target (event bubble). Set to true or false, respectively.
|
See also
DOM 2 Events dispatchEvent | () | method |
public function dispatchEvent(event:Event):Boolean
Introduced in: | DOM 2 Events |
Modified in: | DOM 3 Events |
Dispatches an event to fire on a node artificially.
Note (IE): IE's equivalent of dispatchEvent() is fireEvent().
Parameters
event:Event — The event to be dispatched.
|
Boolean — Indicates whether any of the listeners which handled the
event called Event.preventDefault(). If Event.preventDefault() was
called the returned value is false, else it is true.
|
EventException — UNSPECIFIED_EVENT_TYPE_ERR:
Raised if the Event.type was not specified by initializing the event
before dispatchEvent was called. Specification of the Event.type as
null or an empty string will also trigger this exception.
| |
EventException — DISPATCH_REQUEST_ERR: Raised
if the Event object is already being dispatched.
| |
DOMException — NOT_SUPPORTED_ERR: Raised if the Event
object has not been created using DocumentEvent.createEvent().
| |
DOMException — INVALID_CHARACTER_ERR: Raised if
Event.type is not an NCName as defined in [XML Namespaces 1.1].
|
See also
<div id="test" onclick="alert('hi')">Sample DIV.</div> <script type="text/javascript"> //Generate an artificial click event on "test". Fires alert("hi") var clickevent = document.createEvent("MouseEvents"); clickevent.initEvent("click", true, true); document.getElementById("test").dispatchEvent(myevent); </script>
DOM 2 Events removeEventListener | () | method |
public function removeEventListener(type:DOMString, listener:EventListener, useCapture:Boolean):void
Introduced in: | DOM 2 Events |
Removes an event listener.
Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect. The Event.namespaceURI for which the user registered the event listener is implied and is null.
Parameters
type:DOMString — Specifies the Event.type for which the user registered
the event listener.
| |
listener:EventListener — The EventListener to be removed.
| |
useCapture:Boolean — Specifies whether the EventListener being removed
was registered for the capture phase or not. If a listener was
registered twice, once for the capture phase and once for the target
and bubbling phases, each must be removed separately. Removal of an
event listener registered for the capture phase does not affect the
same event listener registered for the target and bubbling phases,
and vice versa.
|
See also
DOM 3 Events removeEventListenerNS | () | method |
public function removeEventListenerNS(namespaceURI:DOMString, type:DOMString, listener:EventListener, useCapture:Boolean):void
Introduced in: | DOM 3 Events |
Removes an event listener. Calling removeEventListenerNS with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.
Parameters
namespaceURI:DOMString — Specifies the Event.namespaceURI associated with the event for which the user registered the event listener.
| |
type:DOMString — Specifies the Event.type for which the user registered
the event listener.
| |
listener:EventListener — The EventListener to be removed.
| |
useCapture:Boolean — Specifies whether the EventListener being removed
was registered for the capture phase or not. If a listener was
registered twice, once for the capture phase and once for the target
and bubbling phases, each must be removed separately. Removal of an
event listener registered for the capture phase does not affect the
same event listener registered for the target and bubbling phases,
and vice versa.
|
See also