detect-mobile-browser
detect-mobile-browser copied to clipboard
False positive for Firefox on Windows
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
I am also experiencing this.
SmartPhone.isAny()
is returning true for Firefox on Window 7 for me.
Same here for Firefox on OSX El Capitan.
Same issue here on OSX 10.12, makes the library impossible to use I'm afraid :/
@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?
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
It returns true every time on Firefox windows 7,8,10
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