Subject: | This code looks at a field that can... |
Summary: | Package rating comment |
Messages: | 5 |
Author: | Stephen Chapman |
Date: | 2012-11-30 23:09:27 |
Update: | 2012-12-01 23:27:43 |
|
|
|
Stephen Chapman rated this package as follows:
Utility: | Bad |
Consistency: | Not sure |
Examples: | Sufficient |
|
Stephen Chapman - 2012-11-30 23:09:27
This code looks at a field that can be set to any value by the user in order to work out whether the browser is running on a mobile device or not. If I included a reference to 'android' in that field for Internet Explorer or Firefox running on a computer then the script would think the computer was a mobile device.
The navigator.useragent field is only useful for statistical purposes and should never be used for anything where accuracy is required.
Arturs Sosins - 2012-12-01 09:49:12 - In reply to message 1 from Stephen Chapman
Nowadays everything can be faked, from navigator information, to IP address and screen sizes.
There is no guaranteed way to detect it, only solution is to guess and this one is the best you could use in javascript.
I'm sorry it was not what you expected, but take notice that there is no need for most users to change the navAgent string because information provided in it is often used to provide better browsing experience for them.
This besides I think that most of the Internet users, don't even know what user Agent is, don't even mention on how to change it.
Stephen Chapman - 2012-12-01 22:11:50 - In reply to message 2 from Arturs Sosins
All the serious mobile detectors I have seen use the width of the browser viewport to make the distinction. Media queries all use that method.
Using the browser viewport width will work even if someone does fake it since if web pages need to be displayed within the specified width regardless - if their browser is only open to a width of 200px then it needs to use the mobile version of the page even if displaying on a 1920px widescreen as with the browser that small the desktop version of the page will not fit in the browser.
Stephen Chapman - 2012-12-01 22:20:22 - In reply to message 3 from Stephen Chapman
Arturs Sosins - 2012-12-01 23:27:43 - In reply to message 4 from Stephen Chapman
Yes, but you see from my point of view, I don't need to just know if its mobile or not. I needed to try to guess whether it is IOS or android or kindle or samsung device, to redirect link to proper app market.
There is no way to establish it using screen width. That's the whole purpose of the package.
;)
|