4

What are the possible checks can be made to detect firefox features using modernizr?

Natto
  • 213
  • 1
  • 4
  • 17
  • Browser detection is not recommended more. Feature detection is the way forward. As such, Modernizr won't let you do it; you'll have to inspect the `userAgent` string manually and check yourself (see http://stackoverflow.com/questions/7000190/detect-all-firefox-versions-in-js) – Matt Jul 03 '12 at 20:07
  • The entire point of Modernizr is to perform feature detection instead of client-agent detection. There may be a way to do it, but it's contrary to the larger aim of the tool. – apsillers Jul 03 '12 at 20:09
  • Are you satisfied with a method which matches all browsers which are using the Gecko layout engine? – Rob W Jul 03 '12 at 20:52
  • If browser detection shouldn't be used, then what about the way IE doesn't trigger a change event on making a selection from a list type input until removing focus? – David Apr 24 '13 at 05:31
  • IE7 and under, that is. The kind that leads to code like this: if ($.browser.msie && $.browser.version < 8) input.bind('click', function () { $(this).trigger('change'); }); – David Apr 24 '13 at 05:38
  • The best answer I found: http://stackoverflow.com/questions/9847580/how-to-detect-safari-chrome-ie-firefox-and-opera-browser – Max Stern Dec 04 '16 at 20:20

2 Answers2

19

Even if browser detection is not recommended for features it could be use to present other type of information.

Modernizr.addTest('firefox', function () {
 return !!navigator.userAgent.match(/firefox/i);
});

This adds a class .firefox to document.documentElement (html tag)

pdjota
  • 3,163
  • 2
  • 23
  • 33
6

Browser detection is unfortunately still necessary for things like video and audio since all browsers promote different formats. I think you'll find your answer here, Natto:

http://diveintohtml5.info/detect.html