Detect all Firefox versions in JS

Mirgorod picture Mirgorod · Aug 9, 2011 · Viewed 127.2k times · Source

How to detect Firefox in JavaScript?
I want to detect all versions of Firefox.

Answer

Rion Williams picture Rion Williams · Aug 9, 2011

This will detect any version of Firefox:

var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;

more specifically:

if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1){
     // Do Firefox-related activities
}

You may want to consider using feature-detection ala Modernizr, or a related tool, to accomplish what you need.