mobile version.

Hi, I am building 3 layouts of the same site: 1 for the web, 1 for the iphone, 1 for the mobile (xhtml mp). I know if the request of my site is from iphone with this string:

request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Mobile/.+Safari)/]

How can I know when the request is from mobile or (in fact the same result) is from internet web browsers?

Matteo.

Have you searched the web for the user agent strings of the most common mobile phones that have web capabilities to see if there is some common string to can key off of?

Okay. After a quick search it appears the detection of mobile devices is somewhat non-trivial. Solutions extend from building arrays of "common" user agent strings for various mobile devices through the use of comprehensive XML files containing information about the capabilities of mobile devices. Here's is an example of one I was able to find:

There are other examples that may do the trick for the more common mobile devices. But, there appears to be no consistent string that guarantees whether the device is mobile or not. At least not that I have found in my quick search.

Robert Walker wrote:

Have you searched the web for the user agent strings of the most common mobile phones that have web capabilities to see if there is some common string to can key off of?

Yes, I searched for mobile device user agent and I found just single user agent list like this:

But I hope to find a code for detecting all mobiles request instead to create a long list to manage. I think this is more useful.

http://wurfl.sourceforge.net/

I think this is the best solution. I think to keep the list from the file and check the user_agent. Thank a lot! M.

If it helps I found also this resource:

http://www.useragents.org/database-useragents.asp

Is in italian but there are common links like browser, robots, sistema operativo (os). And there is a rss: http://www.useragents.org/database-useragents.asp