Categories
Software and Programming

addEvent (and other joys of Javascript)

QuirksMode is a great resource documenting the various, umm, quirks of how Javascript is implemented in different browsers. A while ago, the site ran a contest soliciting the public to write a better version of Scott Andrew’s classic addEvent script. The version they chose as a winner is short and sneaky, but the real gold is in the ensuing comments, where several clever people vie to improve on it and on each other’s version.

In other Javascript news, here’s a story about someone who put a sneaky Javascript “virus” in his user profile on a social networking site called MySpace, which got thousands of users to unwittingly add him to their “friends” list and add the line “Samy is my Hero” to their profile. It’s worth reading how he did it if you’re ever involved in making a site that lets users add arbitrary HTML to their user pages.