[Javascript] Differences with event handlers

Matt Warden mwarden at gmail.com
Mon Jul 12 08:54:11 CDT 2010


On Mon, Jul 12, 2010 at 9:50 AM, Terry Riegel
<riegel at clearimageonline.com> wrote:
> Hello All,
>
> I have an issue with event handlers and am not sure how to resolve it...
>
> I can handle a click event for an anchor one of two ways...
>
>
> 1. anchorObj.addEventListener( 'click', fn, false ); // or attachEvent
>
> or
>
> 2. anchorObj.onclick=fn;
>
>
> With the second method I can "return false;" from fn and it stops the browser from doing the normal thing, but with the addEventListener it still sends the anchor.
>
> What is the best way to get the first method to work like the second one.
>
> Thanks,

Cancel the event and its bubbling up the DOM.

http://www.quirksmode.org/js/events_order.html


-- 
Matt Warden
Cincinnati, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the Javascript mailing list