OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to detect Firefox mobile with javascript?

  • Thread starter Thread starter mheavers
  • Start date Start date
M

mheavers

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

Code:
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:

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

and

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

I visited whatismyuseragent.com and got the following:

Code:
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.

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

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

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

<pre><code>var isFirefox = navigator.userAgent.match(/Mozilla/i != null);
</code></pre>

<p>and</p>

<pre><code>var isFirefox = navigator.userAgent.match(/Firefox/i != null);
</code></pre>

<p>I visited whatismyuseragent.com and got the following:</p>

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

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

Latest posts

Top