spacer
Yehuda Shiran January 1, 2001
The Netscape 6 Event Listener
Tips: January 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Netscape 6 introduced a new event concept, the event listener. You attach an event listener to an object. The event listener listens for a specified event, and when the event occurs, the event listener executes a pre-specified action. You can define several event listeners for the same object, and for the same event type. For example, two separate event listeners can listen to a click event for a specific button, and execute two different actions. You add an event listener by the addEventListener() method:

object.addEventListener(eventType, functionCall, downBool)
where:

  • eventType is the type of the event you want to listen to. Do not include the "on" prefix. Examples: "mouseover", "click", "mouseout", "mouseup", and "mousedown".
  • functionCall is the function you want to execute when the event is detected. This is the actual function reference and not a string, so don't include the function name in quotes. If you need to pass parameters to the function, simply pass them in this call, as functionName(param1, param2).
  • downBool is a Boolean variable (true or false) that tells the listener on which phase to intercept the event. A true value asks the listener to intercept the event on its way down from the browser window object to its target object (capture phase). A false value signals the listener to intercept it on its way up from the target object to the window object (bubbling phase).


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint