Search code examples
jquerybrowser-feature-detectionjquery-1.4

Feature detection for jquery 1.4


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?


Solution

  • 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