Cross-browser dynamic JavaScript events with DOM

I have wrestled at length with a good DOM-based way to dynamically add JavaScript events to a page.  After much Googling, I pieced the following together from a number of different suggestions (credit to whoever you are). I eventually gave up on DOM because IE’s implementation is so broken, but this part works well.

It uses eval() to execute the action, so it’s not the most elegant thing, but it’s functional.

Example and source:

One Response to “Cross-browser dynamic JavaScript events with DOM”

  1. Trav Says:

    Ummmmmmm……

    Okay!

    :)

Leave a Reply