views:

222

answers:

2

How would I go about doing a detect to see if the browser is either firefox, ie (but not ie6), opera, chrome or safari by using feature detection?

+3  A: 

Feature detection is not supposed to tell you which browser the user is using. It is meant to tell you if the browser can handle what you need to do.

So for instance, if you need to support ActiveX, you might check

if(ActiveXObject) { ... }

This is better than checking if the browser is IE because some other browser (current or future) might support ActiveX too.

A more useful example may be text node checking when traversing a node list.

if (!el.tagName || el.tagName != expectedTagName)
    el = el.nextSibling;    // skip the text node
Joel Potter
A: 

For Safari: I'm going the server side route, ie using Chris Schuld's Browser.php; apart from the http user agent there's very little documentation about Safari feature detection.

theman