Detect all Firefox versions in JS

前端 未结 7 1961
-上瘾入骨i
-上瘾入骨i 2020-11-27 03:04

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

7条回答
  •  情书的邮戳
    2020-11-27 03:39

    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.

提交回复
热议问题