Simple Mobile Phone Detection

Posted 2009-02-12 in Mobile Web by Johann.

Looking for an easy and simple way to detect mobile browsers?

This regular expression should be able to detect most popular mobile phone browsers:

(IEMobile|Windows CE|NetFront|PlayStation|PLAYSTATION|like Mac OS X|MIDP|UP\.Browser|Symbian|Nintendo|Android)

Explanation

  • IEMobile selects newer Windows Mobile browsers.
  • Windows CE selects older Windows Mobile browsers.
  • NetFront obviously selects NetFront browsers.
  • PlayStation and PLAYSTATION select the PlayStation browsers.
  • like Mac OS X selects iPhone and iPod browsers.
  • MIDP selects most BlackBerry and Opera Mini browsers.
  • UP.Browser selects OpenWave-based browsers.
  • Symbian selects Opera browsers for Symbian.
  • Nintendo selects Opera browsers on Nintendo.

There are a few rare other mobile browsers not covered by this regular expression. Do you know of some that should be included? Please post a comment!

13 comments

#1 2009-02-12 by Lukoko

Safari/413 detects Symbian WebKit browsers
Safari/525 for iPhone
Obigo for Obigo browsers
J2ME for Opera Mini

mind that MIDP is not only for BB and Opera Mini, you can find it on Mototorola, LG, Nokia S40, etc.

#2 2009-02-12 by Lukoko

Sorry I did't mind that you want to detect mobile browser only, not brand of mobile broser

#3 2009-02-13 by lordhong

blackberry for all RIM devices
webkit for Nokia S60, iPhone/iPod Touch, Android, Palm Pre etc.

#4 2009-02-13 by Johann

Lukoko,

exactly, but let's go through your list: Safari is already detected by like Mac OS X. I haven't seen Obigo, but MIDP will detect Opera Mini.

lordhong,

same as above, MIDP will detect BlackBerry browsers. WebKit doesn't work because it's used in desktop browsers as well.

#5 2009-02-13 by Lukoko

Johan,
Sorry, I thought it is about recognising the type of browser, not just detect any mobile browser. I prefer to adjust the page for each browser.

#6 2009-04-03 by Turko

This can be a good solution, the Mobile Browser Definition File available on http://mdbf.codeplex.com/ contains definitions for individual mobile devices and browsers. At run time, ASP.NET uses the information in the request header to determine what type of device/browser has made the request.

#7 2009-04-06 by Johann

Turko,

thanks for the info. Is this extracted from WURFL?

#8 2009-06-15 by Idel

I have published the new version of Apache Mobile Filter, now the filter is give to you the information of capabilities as apache environment.
Now you can develope in any language (php,jsp, ruby etc.) and have the information of mobile capability.

Read more info here: http://www.idelfuschini.it/it/apache-mobile-filter-v2x.html

#9 2009-06-26 by Johann

Idel,

thanks for the update. I find it an interesting idea to put the device detection in the web server. Also, I wasn't aware you could access Apache environment variables in Tomcat.

#10 2009-06-26 by Idel

Johann,
if you want pass environment variabe in tomcat this is possible.
You need to configure httpd.conf with this command:

JkEnvVar AMF_MAX_IMAGE_HEIGHT undefined

and to retrieve the value from Tomcat:

request.getAttribute("AMF_MAX_IMAGE_HEIGHT")

#11 2009-07-04 by Flips

Adroid sends 'smartphone' and my Windows Mobile Handy does also.

#12 2009-07-04 by Johann

Flips,

thanks, I added Android for the Android ones but I don't know about your Windows Mobile cellphone -- I should have those covered. Post your user agent please if I didn't.

#13 2009-11-25 by Danny

Thought that handsetdetection.com might also be a good service for you to know about - we use it for mobile analytics and also for customizing the view based on actual screen size for each mobile device.

it is basically a front end to Wurfl..

Subscribe

RSS 2.0, Atom or subscribe by Email.

Top Posts

  1. DynaCloud - a dynamic JavaScript tag/keyword cloud with jQuery
  2. 6 fast jQuery Tips: More basic Snippets
  3. xslt.js version 3.2 released
  4. xslt.js version 3.0 released XML XSLT now with jQuery plugin
  5. Forum Scanners - prevent forum abuse
  6. Automate JavaScript compression with YUI Compressor and /packer/

Navigation