I recently came up with a need to handle things a little bit differently for Internet Explorer. Can you believe it? IE doesn't behave the same way as other browsers... There are a lot of different ways to detect the browser in javascript, so I was hoping to just go out and find a library or function that was already written and was reasonably reliable.
I came accross this script at QuirksMode, which I thought was pretty complete - it doesn't report the browser version information for Safari, but aside from that it is one of the more complete and robust browser detection utilities available.
The script is simple to use, and can easily be added to existing javascript files, or pulled in separately via a script link.
Browser detection is something that most javascript people frown upon - because it is inherently unreliable, but this situation called for it. Many people would tell you to use object detection methodologies - which this script makes use of for some browsers. Another solution would be to use the prototype.js library's Try.these funciton which will try several different functions until it processes one without finding an error. In my particular situation, IE supported the funcitonality I required - it just didn't behave properly during practical usage.
Join The Javascript Browser Detection Discussion
