I have just built a mobile site and want to redirect the traffic from our main site if the user is browsing through a mobile phone.
Currently I am using javascript to pick up the browser useragent and using that to identify if the device is a mobile phone.
The issue I have is with Android devices as I cannot find a distinguishing feature for Android useragents to decide whether the device is a phone or a tablet, If the user is on a tablet I still want to show them the full site.
Does anyone know of a solution for this?
To detect if the user is using a mobile device in JavaScript, we can use the userAgent property. This property is part of the navigator object and sent by the browser in HTTP headers. It contains information about the name, version, and platform of the browser.
The easiest way to check your phone's model name and number is to use the phone itself. Go to the Settings or Options menu, scroll to the bottom of the list, and check 'About phone', 'About device' or similar. The device name and model number should be listed.
You should probably use this sugestion made by google by reading the user agent. If the UA has the word mobile it's a phone, if it doesn't it's a tablet
http://googlewebmastercentral.blogspot.com/2011/03/mo-better-to-also-detect-mobile-user.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With