GetEventListeners

From FirebugWiki

(Difference between revisions)
Jump to: navigation, search
m (Fixed some grammar mistakes)
Line 1: Line 1:
-
Returns all the event listeners registered for specific node. ''This feature has been introduced in Firebug 1.12''
+
Returns all the event listeners registered for specific target. The target can be a node or a DOM property.
 +
 
 +
''This feature has been introduced in Firebug 1.12.''
== Syntax ==
== Syntax ==
<source lang="javascript">
<source lang="javascript">
-
getEventListeners(node)
+
getEventListeners(target)
</source>
</source>
== Parameters ==
== Parameters ==
-
=== node ===
+
=== target ===
-
The element (event target) for which registered listeners are returned.
+
The event target for which registered listeners are returned.
== Examples ==
== Examples ==
Line 23: Line 25:
</source>
</source>
-
The Console panel result is a simple object an array for each event type (e.g. "click" or "mousemove"). The following screenshot shows that there are two ''click'' and one ''mousemove'' registered listeners on ''document.body'' element.
+
The Console panel result is a simple object containing an array for each event type (e.g. "click" or "mousemove"). The following screenshot shows that there are two ''click'' and one ''mousemove'' listeners registered on the ''<body>'' element.
[[File:GetEventListeners1.png]]
[[File:GetEventListeners1.png]]
-
 
+
If you want to see more about registered listeners, click the green object in the [[Console Panel]] and you'll be navigated to the [[DOM Panel]]. See the next screenshot.
-
If you want to see more about registered listeners click on the green object in the Console panel and you'll navigated to the DOM panel. See the next screenshot.
+
[[File:GetEventListeners3.png]]
[[File:GetEventListeners3.png]]
-
Every item in the arrays describes particular listener. You can see if ''useCapture'' is set and name of the function used as the listener handler. If you click the function you'll be navigated to the Script panel to see its source code.
+
Every item in the arrays describes a particular listener. You can see whether ''useCapture'' is set and the name of the function used as the listener handler. If you click the function, you'll be navigated to the [[Script Panel]] to see its source code.
== See also ==
== See also ==
* [[Command Line API]]
* [[Command Line API]]

Revision as of 17:37, 17 July 2013

Returns all the event listeners registered for specific target. The target can be a node or a DOM property.

This feature has been introduced in Firebug 1.12.

Contents

Syntax

getEventListeners(target)

Parameters

target

The event target for which registered listeners are returned.

Examples

An example of a web page that registers three listeners:

document.body.addEventListener("click", function onClick1() {}, true);
document.body.addEventListener("click", function onClick2() {}, true);
document.body.addEventListener("mousemove", function onMouseMove1() {}, true);

This is what you execute on the Command Line.

getEventListeners(document.body);

The Console panel result is a simple object containing an array for each event type (e.g. "click" or "mousemove"). The following screenshot shows that there are two click and one mousemove listeners registered on the <body> element.

GetEventListeners1.png

If you want to see more about registered listeners, click the green object in the Console Panel and you'll be navigated to the DOM Panel. See the next screenshot.

GetEventListeners3.png

Every item in the arrays describes a particular listener. You can see whether useCapture is set and the name of the function used as the listener handler. If you click the function, you'll be navigated to the Script Panel to see its source code.


See also

Personal tools