[Javascript] Differences with event handlers

Terry Riegel riegel at clearimageonline.com
Mon Jul 12 08:50:23 CDT 2010


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,

Terry


More information about the Javascript mailing list