Mobile device detection for rendering rich web content

眉间皱痕 提交于 2019-12-01 08:49:56

问题


  1. What are the most web-capable mobile phones to date (models and / or user agents) and

  2. What rules should be assessed when trying to determine if they will handle a rich mobile-customised site?

I am developing a mobile website and currently doing some user agent detection to determine if the mobile device should see a fully enhanced js, jquery mobile, css view, or plain a fallback one.

Here is what I currently have for my two questions, and I would like some input / suggestions on how this can be improved - this filtering is assessed top-to-bottom:

Enhanced view if the user agent contains the following: "iPhone", "iPad", "Android 3", "Android 2", "MSIE 9", "MSIE 8", "MSIE 7", "Windows Phone OS 7", "IEMobile/7", "BlackBerry99", "BlackBerry 9800", "BlackBerry Tablet"

then Fallback view if the user agent contains the following: "Android 1", "MSIE 6", "MSIE 5", "MSIE 4", "MSIE 3", then there are a whole bunch of old blackberry UAs i.e. "BlackBerry8" and older Opera Mini versions i.e. "Opera Mini/3"...

then Enhanced view if found to be a web browser (also helpful for testing reasons). This is again determined by user agent rules.

then Fallback view when the user agent is loaded (and found) in the WURFL API and the release date is found to be too old. At the moment I am considering this to be prior to 2007.

then Fallback view when the WURFL device_os capability shows 'Windows Mobile OS' with device_os_version capability '5', or '6'.

then Enhanced view as could not determine what they are using, so give the best experience (this will cater for new release handsets)

The way this is set up, it is better to find reasons to exclude a device than to include one, as the last condition will return the enhanced view.


回答1:


What are the most web-capable mobile phones to date (models and / or user agents)

I think you've already identified the most important ones: iOS devices, Android 2.0+, and recent BlackBerry devices. But really, if you want to know how well your site is supported, you should check out the emulators/simulators available for particular devices.

An excellent list of example User-Agent strings can be found here.

What rules should be assessed when trying to determine if they will handle a rich mobile customised site?

BlackBerry devices running OS 6.0 or higher will have a WebKit-based browser which supports the latest goodies, so you could improve your filtering for BlackBerry devices to anticipate new/unreleased devices that will work well. The following User-Agent example shows that the device is running OS 6.0.0.141:

Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, Like Gecko) Version/6.0.0.141 Mobile Safari/534.1+

Prior to OS 6.0, the BlackBerry User-Agent looked a bit different (and the web browser experience was much worse). The following User-Agent example shows that the device is running OS 4.7.1.40:

BlackBerry9630/4.7.1.40 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105



回答2:


If the device supports preferred_markup = html_web_4_0

From WUFL



来源:https://stackoverflow.com/questions/6066848/mobile-device-detection-for-rendering-rich-web-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!