You learn something new every day, which is why I love being alive.
Its an astounding coincidence that just when I needed to implement a cross browser method of stacking event handlers (for MetaWrap WireWrap), this blog post came out describing exactly how you should not do it.
The issue seemed to be the difference between browsers that implement the W3C spec vs Microsoft’s spec for dynamically adding an event handler.
The key difference is that the
this keyword does not work properly in Microsoft’s
attachEvent. Instead of referring to the element the event handler is defined on, as it does in the W3C model, it refers to the window object.
There is also a memory leak in IE which for which the only solution is to garbage collect ever event handler you ever created, for example – on body.onunload() killing all references to event handlers. This leak is probably based on circular references.
Damned if I’m going to write my own now.