PDA

View Full Version : Mobile Browser Detection




chrisfromboji
06-30-2008, 04:09 AM
Hey,
I'm working on a mobile website and need some help with my mobile browser detection script. I have it working for iPhone, iPod Touch, and Windows Mobile Devices.

I need help getting it to detect for Blackberry Browser (Blackberry Devices), Blazer Browser (Palm Devices), Opera Mini Browser, Opera Mobile Browser, and other mobile browsers if possible.

Does anyone know how to modify (and test if you have a phone to test with, as I don't have all of these devices) this javascript?:

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)))
{location.replace("mobile.html");}
if((navigator.appVersion.indexOf("Windows CE")>0))
{location.replace("mobile.html");}


Thanks for your help!
-Chris

jscheuer1
06-30-2008, 04:30 AM
I'm not sure if this would work, but it is worth a shot. If it works, it should detect all mobiles:

if (screen.width < 800)
window.location.replace('mobile.htm');

Also, if you have those various devices and/or have a friend with one, you can use this to at least see what they report:

http://home.comcast.net/~jscheuer1/side/nav_obj/

chrisfromboji
06-30-2008, 05:19 AM
Interesting script, but I'm more interested in pointing visitors at web pages specifically tailored to their mobile device.

The second link is something that hopefully I might be able to use if I can get a hold of those devices.

I'll keep my eyes open for something more specific.

jscheuer1
06-30-2008, 11:28 AM
You can probably Google that information, for example:

http://na.blackberry.com/eng/developers/resources/journals/mar_2007/bdjs.jsp#Object: navigator Properties

Where you will find that the:

navigator.appName

returns 'BlackBerry'

for the Blackberry Browser.

This page has a wealth of info:

http://www.howtocreate.co.uk/tutorials/jsexamples/sniffer.html

and seems to indicate that:

On PalmOS, the appName is "Blazer"

Anyways, to Google this for any other device and/or browser, just use as search terms:

device name browser name navigator object

Like:

http://www.google.com/search?hl=en&client=opera&rls=en&q=Opera+Mini+Browser+navigator+object&btnG=Search

davemanjra
07-10-2008, 07:39 AM
you can use handsetdetection.com to detect blackberrys and almost every other mobile phone and device.