Is window.navigator.userAgent reliable
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 ?
Based on w3schools, it should be supported by all browsers, so it should be a pretty reliable method for detecting the user agent.
Not very enlightening, what happens to the value of .userAgent if the user changes the browser config ?
It changes. User agent strings are inherently somewhat unreliable.
For what purposes are you trying to detect which device is being used? It's generally better to check viewport (not screen) dimensions and do feature detection instead of relying on user-agent sniffing.
There are dozens and dozens of different mobile devices. Trying to check for each one in your code is not easy (and probably not worth the trouble).
cbrack, please do not post links to that site here. There are better resources elsewhere. I recommend you read this: W3Fools: A W3Schools Intervention
Great, suspicions confirmed, thanks !
June 10th, 2013, 02:33 AM
However ~ 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 ??
June 10th, 2013, 07:39 AM
Why would you need to set the <meta name="viewport"> tag dynamically?
Disabling zoom is very user-unfriendly -- I hope you'd have a very good reason for doing so. What's the smallest touchscreen device you've spent a significant amount of time using for web browsing?
June 10th, 2013, 07:41 AM
Yes, I understood disable zoom on an iPhone (for example) for a responsive web design was best practice.
June 10th, 2013, 09:26 AM