View Full Version : How do I detect for a mobile device?

12-17-2002, 07:33 PM
I have a standard HTML website, but I want to be able to detect when a client is comming from a mobile device, such as a PDA or a Mobile phone.

What is the best way to do this? and is it possible to determine the screen resolution of the device?



12-18-2002, 09:39 AM
Hello. Go for the resolution check option and redirect to relevant pages for each resolution you build the site for.

12-20-2002, 07:29 PM
This is a website: http://www.dailyf1.com/en/
this is the PDA version of the same site: http://www.dailyf1.com/en/pda/index.phtml
It's not only about resolution.

12-20-2002, 07:49 PM
The missing link :) http://hotwired.lycos.com/webmonkey/99/20/index2a.html?tw=eg20000705

12-21-2002, 06:11 PM
Most WAP-enabled devices only have a viewing area of 150x150. You can only reliably detect if they are a WAP enabled device by using a server-side language to check to see if the device accepts certain things, things that are unique to wireless devices.

Basically you check to see if the browser accepts text/vnd.wap.wml. If it does accept this, then it is a WAP enabled device, and thus a handheld.

You would also probably want to check if it is a pocket PC, so then would check if the HTTP_USER_AGENT is Windows CE. If it is, than again, you have a WAP enabled device.

You cannot use JavaScript to do this, as WAP devices do not offer full (and sometimes no) support of scripting blocks or advanced features. It will often simply not parse them.

So in ASP you would use:

If (InStr(Request.ServerVariables("HTTP_ACCEPT"), "text/vnd.wap.wml")) or (InStr(Request.ServerVariables("HTTP_USER_AGENT"), "Windows CE")) then
'redirect to WAP area
End If

in PHP (which I would recommend) it would be:

if ((strpos($HTTP_ACCEPT,'text/vnd.wap.wml')) or (strpos($HTTP_USER_AGENT,'Windows CE'))) {
//this is a WAP device

Technically, you could also do this through a .htaccess file that would affect your site globally, but I haven't tried it (though it would seem to work easily and not require you to have to touch all pages within a site).

12-23-2002, 02:13 PM
Don't you need to use WML for wireless pages? Or do Wireless devices have HTML parsers now?

12-23-2002, 03:17 PM
I dunno... I know Google works on a PDA, do they use WML?

12-23-2002, 05:20 PM
Most devices will parse (they refer to it as 'converting from HTML') to a WML hybrid they can read. WML isn't as mush as a consideration as it once was, but it is still the only reliable way to have a page display within a WAP device properly. (also, since WAP devices don't parse certain functions, only have 4 methods of navigation; so typically a entire new site is served up that strips everything but the bare essentials.) The sites that are really serious about wirelss device accessibility use CMS's that detect a WAP device and alter their layout accordingly, dynamically.

Also, remember that the estimates of wireless device users of the internet is absolute crap...it is a complete lie. 1 billion wireless internet ready devices by 2003...and realize that 99% of that number simply do not use those devices for internet access at the moment, even if their device is ready...those stats simple count how many devices can use the internet, now how many actually do; it is a pipe dream right now: the devices are (for the most part) far too limited for web use.