[thelist] DOM - adding a function to a dynamically addedelement...

Jeff Howden jeff at jeffhowden.com
Mon Apr 25 21:24:32 CDT 2005


Pavel,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: Pavel Dudrenov
>
> First don't use setAttribute cuz' that wont work on IE.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

This simply isn't true.  setAttribute() works just fine in IE6+.

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> [...] or you can use addEventListener/attachEvent
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

The use of addEventListener/attachEvent have the same limitations as
assigning a function to an even handler in the fashion of "object.eventname
= myFunction;".  However, more importantly, you immediately run into browser
compatibility issues requiring method support branching in your code.  I
would personally recommend that you avoid these techniques unless you
specifically need the ability to add scripting to an event handler an
unknown number of times and/or an unknown number of sources.

Jeff
——————————————————————————————————————————————————————
Jeff Howden - Web Application Specialist
Résumé - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/



More information about the thelist mailing list