Brian's ramblings on life, technology and photography... but mostly just purty pictures.

Monday, April 17, 2006

Safari into the DOM

Since I've starting working for Newsgator, I've been writing a lot of Javascript. It's been fun learning the ins and outs of this environment. But as everyone who's written Javascript knows, cross-browser compatibilty is a total pain in the butt.

One particular problem I remember is how Safari sets the eventTarget of mouse events. If you attach an event, an onclick for instance, to a container node with text in it, Safari sends the events to the text instead of the container. I was going to write an example, but QuirksMode does it better.

For the life of me I can't figure out why you would want this. In fact, this is so bizarre to me that it took almost an entire day before the possibility occurred to me, at which point I did some Googling and found the answer. But that was a really frustrating day.

If writing this post saves even one poor web developer the same experience, then it's all worth while. Or something like that.