Is this a reliable means of device detection, ie iPad, iPhone, Android, etc.. ?
Or is there a sensible alternative ?
Is there a definitive list of device names ?
If you are targeting key devices then it would be but a quick search of Google reveals several ways to accomplish device detection.
Not very enlightening, what happens to the value of .userAgent if the user changes the browser config ?
The useragent can be set to anything at all by the person who owns the browser. Firefox, chrome and Opera provide options to make this easier (to change it for IE you need to update the Registry). In Opera you can even set it up to present different useragent values to different web pages.
Since most people don't change it you can rely on its value for gathering statistics but you can't rely on it for anything else.
Google Maps is an example that relies on it entirely. When I loaded it using a blank UA, it slandered the capabilities of what was at the time the current FireFox.
If you have a site with a large and cluttered content area, which is probably ok on a desktop/laptop, surely a responsive design will look rediculous on a smartphone with tiny viewport. In this scenario surely a simplified, optimised design would be better, ie user gets redirected to a separate site for mobile devices. In this case isn't device detection necessary to effect the redirect?
The best way to do device detection is by using media queries to check the viewport size. That way you can use a page layout that will fit the browser viewport regardless of what device it is. It is trivially easy to set up almost any browser on a computer so it has the same viewport size as a mobile device and reports the same useragent as that mobile device so that you have no way to teoll that it is actually being viewed on the computer and that the person doesn't even own the device it claims to be.
Thanks for that.
I suppose .UserAgent used in a post-load js may be useful to determine mobile device or not, and then perhaps dynamically setting the <meta tag scale so that pinch/zoom is disabled ??
This topic is now closed. New replies are no longer allowed.