检查Firefox / Firefox OS / Firefox的Android [英] Check if Firefox/Firefox OS/Firefox for Android

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

问题描述

我正在编写一个代码片段,检查浏览器是否为Firefox / Firefox OS / Firefox for Android。
检查的方法是检测到少量特征的用户代理。

我还没有找到一个更好的方法,例子。

要点在这里:
https://gist.github.com/Mte90/11087393

任何解决方案更专业?

解决方案

据我所知,没有其他办法可以做到这一点,但是我建议你在需要使用特定的东西时进行功能检测,而不是使用user-agent 。例如,您可以使用

  if(navigator.connection)// Network Information API 
if(navigator。电池)//电池状态API

或者使用像 Modernizr


I'm working on a snippet for check if the browser is Firefox/Firefox OS/Firefox for Android. The method for check is the user agent with a little feature detection.

I haven't found a better way with a complete feature detection that cover all the cases.

The gist it's here: https://gist.github.com/Mte90/11087393

Any solution more professional?

解决方案

As far as I know, there is no other way to do this, but I would suggest you do features detection when you need to use something specific, instead of using user-agent. As an example, you can use

if (navigator.connection) //Network Information API
if (navigator.battery) // Battery Status API

Or use a library like Modernizr.

这篇关于检查Firefox / Firefox OS / Firefox的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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