Check if Firefox/Firefox OS/Firefox for Android

对着背影说爱祢 提交于 2019-12-13 04:59:24

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/23171825/check-if-firefox-firefox-os-firefox-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!