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
andPLAYSTATION
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
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.
Sorry I did't mind that you want to detect mobile browser only, not brand of mobile broser
blackberry for all RIM devices
webkit for Nokia S60, iPhone/iPod Touch, Android, Palm Pre etc.
Lukoko,
exactly, but let's go through your list:Safari
is already detected bylike Mac OS X
. I haven't seenObigo
, butMIDP
will detectOpera Mini
.
lordhong,
same as above,MIDP
will detect BlackBerry browsers. WebKit doesn't work because it's used in desktop browsers as well.
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.
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.
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
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.
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")
Flips,
thanks, I addedAndroid
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
- DynaCloud - a dynamic JavaScript tag/keyword cloud with jQuery
- 6 fast jQuery Tips: More basic Snippets
- xslt.js version 3.2 released
- xslt.js version 3.0 released XML XSLT now with jQuery plugin
- Forum Scanners - prevent forum abuse
- Automate JavaScript compression with YUI Compressor and /packer/