基于javascript的firefox浏览器检测

基于javascript的firefox浏览器检测,firefox,Firefox,我有一个基于javascript的web应用程序,我希望它必须在firefox(任何版本)中运行。我已经经历了几个解决方案,包括navigator对象、browserversion特定对象检测等,但没有人提供帮助。请帮忙 您可以尝试以下方法: var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0; // Opera 8.0+ (UA detection to detect Blink/v8-pow

我有一个基于javascript的web应用程序,我希望它必须在firefox(任何版本)中运行。我已经经历了几个解决方案,包括navigator对象、browserversion特定对象检测等,但没有人提供帮助。请帮忙

您可以尝试以下方法:

var isOpera = !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
// Opera 8.0+ (UA detection to detect Blink/v8-powered Opera)
var isFirefox = typeof InstallTrigger !== 'undefined';   // Firefox 1.0+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
    // At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !!window.chrome && !isOpera;              // Chrome 1+
var isIE = /*@cc_on!@*/false || !!document.documentMode; // At least IE6
JSFiddle: