giovedì, gennaio 22, 2009

Detecting Mobile Devices

While exploring ways to detect for mobile devices, I ran across some useful sites:

·         HandsetDetection.com  is a (free) web service that offers the ability to detect which mobile devices are accessing your website.

·         Detecting Smartphones Using JavaScript

·         http://detectmobilebrowsers.mobi/ is a PHP script to detect mobile phones. (It’s $20 for commercial use, and free for private use).

·         There is also a great article at  “A List Apart” article that attempts to use CSS as the main way to detect mobile devices: “Return of the Mobile Style Sheet.” This is something to bookmark, as I think the technique will become more and more useful as more devices make use of implement CSS Media Queries.

·         List of User-Agents (Spiders, Robots, Browser)

Meanwhile, here are a few “quick and dirty” approaches:

JavaScript

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
      document.write ("iPhone/iPod detected from JavaScript.")
}

Classic ASP

strUA = LCase(Request.ServerVariables("HTTP_USER_AGENT"))
If InStr(strUA, "iphone") Then
      response.write ("iPhone detected from ASP")
End If

1 Comments:

Blogger Unknown said...

I've written a JavaScript that detects most JavaScript enabled phones. So far EVERY JavaScript enabled phone I've tested has been successfully detected.

You can download the script and view it at
http://sourceforge.net/project/showfiles.php?group_id=213893&package_id=294248

Or you can view the release notes for the script at
http://sourceforge.net/project/shownotes.php?release_id=632929&group_id=213893

I just wished to let your community know since I feel it is a simple and useful script and there are easy instructions on use included with the script source file.

You can test this script yourself by browsing to my homepage at http://www.gleske.net/ which uses the script to detect mobile browsers and then refers the user to an alternate web page if they are browsing using mobile or no JavaScript. It is a very simple web page that doesn't use any server side scripting.

SAM

2/12/2009 10:22 PM  

Posta un commento

<< Home