[Javascript] onclick and functions

tedd tedd at sperling.com
Mon Aug 14 07:53:59 CDT 2006


At 11:54 AM +0530 8/14/06, Rakesh Pai wrote:
>On 8/12/06, Paul Novitski <paul at juniperwebcraft.com> wrote:
>>At 07:30 AM 8/12/2006, Rakesh Pai wrote:
>>>That said, using a addEvent function is a cleaner way to attach
>>  >handlers to an event.
>>
>>Rakesh,
>>
>>Can you please elaborate on this opinion?  Cleaner in what ways?
>>
>>Thanks,
>>Paul
>
>Sorry for the delayed response. Paul.
>
>addEvent would generally be regarded as a better option for several
>reasons. Firstly, it uses the vastly richer DOM Level 2 event
>registeration technique. Secondly, you can chain together events, and
>attach multiple event handlers to the same event using addEvent, which
>is not possible using element.onclick, since setting a new handler for
>element.onclick would remove the previous event handler. There are
>more benefits, but I can't recollect them - they are largely low level
>details. Unfortunately, since some browsers (read IE) have different
>DOM Level 2 event registeration techniques, it is required to write a
>wrapper to abstract the differences, which is what addEvent does.
>
>If you do a google search for DOM Level 2 event handling or for
>"addEvent" in Google, you should get a lot more information about the
>event registration models, and about why using element.onclick is not
>such a good idea.

Not accordingly to:

<http://www.quirksmode.org/blog/archives/2005/08/addevent_consid.html>

But then again, maybe that article was written for people like me. :-)

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the Javascript mailing list