addEvent() recoding contest entry
Remove border effect.
This is an implementation of my
AddEvent Manager
script. Please see that for an explanation, details and instructions!
Alternatively, here's a short list of the main advantages this function has
over other comparable addEvent() implementations:
- "this" keyword preserved within assigned event handlers.
- Works in IE/Mac too (via DOM0 event model).
- Executes all events in order of assignment (unlike attachEvent-based functions).
- Doesn't allow duplicate function registrations.
- Will allow adding identical methods of non-identical objects (i.e. it doesn't
hash the function source code for a unique key value like some scripts).
- Doesn't leak memory in IE.
- Easily compatible with other event manager scripts for "unobtrusive" usage,
and legacy scripts that "return false" to cancel events.
- Tiny code size - as little as 497 bytes for just addEvent() and 850 bytes
for the whole script with whitespace removed!