Create a gist now

Instantly share code, notes, and snippets.

@Mte90 /ff-check.js
Last active Mar 23, 2017

Embed
What would you like to do?
Check if Firefox/Firefox OS/Firefox for Android
//With locationbar.visible check if not in a webview (like an open web app)
if (locationbar.visible) {
//mozApps used for the open web app and with the user agent check if have MObile (used in Firefox OS)
if (navigator.userAgent.indexOf('Firefox') > -1 && navigator.userAgent.indexOf("Mobile") > -1) {
//Check Firefox OS
} else if (navigator.userAgent.indexOf('Firefox') > -1 && navigator.userAgent.indexOf("Android") > -1) {
//Check Firefox for Android
} else if (navigator.userAgent.indexOf("Firefox") > -1) {
//Check Firefox Desktop
}
}
@kentaromiura

This comment has been minimized.

Show comment
Hide comment
@kentaromiura

kentaromiura Apr 19, 2014

beware of operators precedence
!!"mozApps" in navigator
equals to
'true' in navigator

beware of operators precedence
!!"mozApps" in navigator
equals to
'true' in navigator

@allenfantasy

This comment has been minimized.

Show comment
Hide comment
@allenfantasy

allenfantasy Jan 12, 2016

From the description in MDN it seems that this code would take all Android devices using Firefox as using Firefox OS.

From the description in MDN it seems that this code would take all Android devices using Firefox as using Firefox OS.

@sultaninen

This comment has been minimized.

Show comment
Hide comment
@sultaninen

sultaninen Mar 23, 2017

Unfortunately this does not work for Android 7 / Firefox.

Unfortunately this does not work for Android 7 / Firefox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment