Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to detect firefox mobile with javascript

I'm using the following code to detect whether the browser being used on my mobile site matches a certain crieteria:

var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
if (isiPhone){ alert ('iphone');

but if I attempt to do this for Firefox / Mozilla, I can't get it to work. I've tried:

var isFirefox = navigator.userAgent.match(/Mozilla/i != null);

and

var isFirefox = navigator.userAgent.match(/Firefox/i != null);

I visited whatismyuseragent.com and got the following:

Mozilla/5.0 (Android;Linux armv7l; rv6.0) Gecko/20110811 Gecko Firefox/6.0 Fennec/6.0

Any idea how I properly detect this? I need to write some firefox specific code.

like image 974
mheavers Avatar asked Aug 30 '11 15:08

mheavers


People also ask

How do I inspect Firefox mobile?

All you need to do is right-click on a webpage and you will get an 'Inspect' or 'Inspect Element' option.


1 Answers

var isFirefox = /Android.+Firefox\//.test(navigator.userAgent);

like image 54
Nikita Gavrilov Avatar answered Sep 23 '22 10:09

Nikita Gavrilov