element.addEventListener

  • Revision slug: Talk:DOM/element.addEventListener
  • Revision title: element.addEventListener
  • Revision id: 92192
  • Created:
  • Creator: Yaroukh
  • Is current revision? No
  • Comment 38 words added; page display name changed to 'element.addEventListener'

Revision Content

random notes:

  • I think the "traditional" way should be on a separate page discussing events.
  • The "this" section should be updated to explicitly warn about a common var myObject = {listener: function() { this.doStuff() }, doStuff: function() {alert("yay")} }; addEventListener("load", myObject.listener, false); mistake.
  • registering/removing anonymous functions listeners
  • listener as an object implementing the interface (with possible uses)
  • fourth param, useful for chrome code.

I hope to remember to add this later this week. --Nickolay 14:24, 28 March 2006 (PST)

I know that in Gecko at least, even if you just add a javascript function event listener, it is passed the event, so you can use something like:

function modifyText(aEvent) {
  aEvent.target.nodeValue = "pants";
}

to get hold of the object. I'm not sure if that's a Gecko bug or some specification in the DOM though.

--DigDug 10:21, 14 Feb 2008 (CST)

Ad "useCapture" parameter: Does the long (and IMO confusion-prone) explanation of this parameter mean anything else than simple "handler will be triggered during capturing phase of the event propagation"?

Revision Source

<p>random notes:</p>
<ul> <li>I think the "traditional" way should be on a separate page discussing events.</li> <li>The "this" section should be updated to explicitly warn about a common <code>var myObject = {listener: function() { this.doStuff() }, doStuff: function() {alert("yay")} }; addEventListener("load", myObject.listener, false);</code> mistake.</li> <li>registering/removing anonymous functions listeners</li> <li>listener as an object implementing the interface (with possible uses)</li> <li>fourth param, useful for chrome code.</li>
</ul>
<p>I hope to remember to add this later this week. --<a href="/User:Nickolay" title="User:Nickolay">Nickolay</a> 14:24, 28 March 2006 (PST)</p>
<p>I know that in Gecko at least, even if you just add a javascript function event listener, it is passed the event, so you can use something like:</p>
<pre class="eval">function modifyText(aEvent) {
  aEvent.target.nodeValue = "pants";
}
</pre>
<p>to get hold of the object. I'm not sure if that's a Gecko bug or some specification in the DOM though.</p>
<p>--<a href="/User:Wjjohnst" title="User:Wjjohnst">DigDug</a> 10:21, 14 Feb 2008 (CST)</p>
<p>Ad "useCapture" parameter: Does the long (and IMO confusion-prone) explanation of this parameter mean anything else than simple "handler will be triggered during capturing phase of the event propagation"?</p>
Revert to this revision