Is there a way to detect if the user is using a tablet or a phone? As an example a person surfing the web using a tablet (any android tablet with version 3+ and iPad) they would surely like to view the same not stripped down version as a person sitting with a desktop computer. And a phone surfer would surely prefer the stripped down version of the site because its quicker to load and might be easier to navigate with your thumb. This could be done with checking userAgent oct screen width found here:
What is the best way to detect a mobile device in jQuery?
But the problem comes with a phone like Google Galaxy Nexus which has the same resolution as a tablet but only half the screen size. In my opinion it would be nicer to show the mobile version since the screen is small even though the resolution is high.
Is there a way to detect this or do I have to make a compromise?
An Android tablet is a tablet-sized PC that runs on Google's Android operating system (OS). Android tablets include almost all the key features found in a regular tablet PC, including office applications, games, Web browsers and many other programs.
A tablet can function as a unified communication device, covering all forms of communication, including the equivalent of a phone call and text message — all without the phone network. And a tablet can function as a laptop, too.
Open 'Settings' and then 'About tablet' on the bottom left side. Then you will find 'Device name' (e.g. “Galaxy Tab A (2016)”) and 'Model number' (e.g. “SM-T585”) below. After choosing 'Software information', you'll see the 'Android version' (e.g. “7.0”).
I think you're making a fundamentally arbitrary distinction between tablet, phone, or any other web enabled device here. It seems like the physical dimensions of the screen is the metric you want to use to dictate the content you serve.
In this case I would try to implement logic based on values passed by the user agent in the HTTP headers ([mobiforge.com...]) and degrade gracefully to prompting the user if information isn't available.
Your logic might look a bit like this:
Update: My answer is now three years old. It's worth noting that support for responsive design has progressed significantly and its now common to deliver the same content to all devices and rely on css media queries to present the site in a way that is most effective for the device it is being viewed on.
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