detect-mobile-browser icon indicating copy to clipboard operation
detect-mobile-browser copied to clipboard

False positive for Firefox on Windows

Open sokraflex opened this issue 9 years ago • 7 comments

Hello there,

another strange bug seems to appear: SmartPhone.isAny() says true when opening the web page with Firefox on Windows 10 Desktop.

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0 ... matches of course the check of return this.getUserAgent().match(/Firefox/i);

I don't know how to detect the mobile Firefox, but a solution could be using a mix of platform and user agent detection like:

return this.getUserAgent().match(/Firefox/i) && navigator.platform.match(/android/i);

This would work for all phones except the FirefoxOS as Firefox is currently only deployed to android. But in cause of my lack of experience with mobile firefox I don't commit this as a pull request and I'm only suggesting it here. Also, this solution would break the Node.JS-support.

Greetings

sokraflex avatar Aug 27 '15 17:08 sokraflex

I am also experiencing this.

SmartPhone.isAny() is returning true for Firefox on Window 7 for me.

Bennethon avatar Aug 02 '16 23:08 Bennethon

Same here for Firefox on OSX El Capitan.

Greta avatar Aug 25 '16 17:08 Greta

Same issue here on OSX 10.12, makes the library impossible to use I'm afraid :/

Anahkiasen avatar Dec 19 '16 09:12 Anahkiasen

@Anahkiasen @Greta @Bennethon did you come up with a solution for this or an alternative library?

@smali-kazmi Thoughts on what the fix might be?

oyeanuj avatar Mar 08 '17 01:03 oyeanuj

Hi everyone! After reading https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox I edited simply the function isFirefox adding a piece of code like this: SmartPhone.isFireFox = function() { return (this.getUserAgent().match(/Firefox/i) && (this.getUserAgent().toLowerCase().indexOf("mobile")>-1 || this.getUserAgent().toLowerCase().indexOf("tablet")>-1)); }; For me is working on Mac OS but i can suppose that will work well also on windows and mobile devices. Bye, Simone

simar88 avatar Apr 18 '17 09:04 simar88

It returns true every time on Firefox windows 7,8,10

Rohit-shopasky avatar Jun 13 '17 11:06 Rohit-shopasky

I'm also experiencing the same issue on Linux Mint and macOS. Here are the exact versions and user agents:

  • Linux Mint 21.1 Cinnamon and Firefox 114.0.2 (64-bit)
    • User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/114.0
  • macOS Ventura 13.4.1 (22F82) and Firefox 114.0.2
    • User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/114.0

I have also created a CodeSandBox for quick testing. Here is the link: https://codesandbox.io/s/detect-mobile-browser-t7cly9

antonio-gg-dev avatar Jun 23 '23 07:06 antonio-gg-dev