W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2002

how to implement interfaces?

From: alex <shortestpath@yahoo.com>
Date: Sun, 20 Jan 2002 21:56:25 -0800 (PST)
Message-ID: <20020121055625.26947.qmail@web14508.mail.yahoo.com>
To: www-dom@w3.org
I'm confused about how you actually go about 
implementing a dom interface. For example, 
I have an image and want it to respond to 
certain events. Using javascript...

// my image has id="arrowUp"
var arrowUp = document.getElementById("arrowUp");

// Now I have the arrowUp node, and nodes implement
// the EventTarget interface; I add an event listener:

arrowUp.addEventListener("mousedown", [listener], false);

My problem is, I'm not sure what to put for [listener].
I read an article somewhere where you can just write
the name of a javascript function that'll do whatever
on the mousedown event on the image. (I've tried this,
it worked.)

However, I'd like to be able to have my arrowUp node 
(or image? which leads me to another question- is the
arrowUp node and the arrowUp image synonymous at this
point?) itself be the listener; that is, have something 

arrowUp.addEventListener("mousedown", arrowUp, false);

But to do this, arrowUp has to implement the EventListener
interface (someone please correct me if my thinking's all
wrong here). I guess this is where my troubles come from.

How do I make arrowUp implement the EventListener interface?

Any help on this is *greatly* appreiciated!

Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
Received on Monday, 21 January 2002 01:31:33 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:09 UTC