addEvent()
recoding contest entryThe code was built using the most simple JavaScript methods to avoid dependencies and we also aimed at the code size, so it does work in browsers that don't support attachEvent/addEventListener. The function also guaranties that the event object has the most requested methods/properties: "preventDefault()", "stopPropagation()", "target" and "key" (the last one behaves like the "keyCode" on IE). We tested and didn't found memory leaks though.
IE 4 | OK. But an exception is raised if we try to add new properties to the event object. We solved this by adding a "try/catch" statement, the counterpart is that there won't be a so-called "standarlized event" on IE 4 (without adding some extra-code). And we also added a work-around to reproduce the "call" method. |
IE 5.1 | OK. |
IE 5.5 | OK. |
IE 6 | OK. |
Opera | OK. |
Firefox | OK. |
Carlos R. L. Rodrigues <rodrigolr@uol.com.br> and Jonas Raoni Soares Silva <jonasraoni@gmail.com> at http://www.jsfromhell.com