Detect all Firefox versions in JS

前端 未结 7 1949
-上瘾入骨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:49

    For a long time I have used the alternative:

    ('netscape' in window) && / rv:/.test(navigator.userAgent)
    

    because I don't trust user agent strings. Some bugs are not detectable using feature detection, so detecting the browser is required for some workarounds.

    Also if you are working around a bug in Gecko, then the bug is probably also in derivatives of Firefox, and this code should work with derivatives too (Do Waterfox and Pale Moon have 'Firefox' in the user agent string?).

提交回复
热议问题