在 JS 中检测所有 Firefox 版本 [英] Detect all Firefox versions in JS

查看:24
本文介绍了在 JS 中检测所有 Firefox 版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在 JavaScript 中检测 Firefox?
我想检测所有版本的 Firefox.

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

推荐答案

这将检测任何版本的 Firefox:

This will detect any version of Firefox:

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

更具体地说:

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

您可能需要考虑使用特征检测 ala Modernizr 或相关工具来完成您的任务需要.

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

这篇关于在 JS 中检测所有 Firefox 版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆