PDA

View Full Version : Mobile Browser Detection



chrisfromboji
06-30-2008, 03: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, 03: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, 04: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, 10: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

ifuschini
07-07-2009, 09:59 AM
I have published the last version of "Apache Mobile Filter", this open source project have, in the first six months, more than 600 downloads from sourceforge and I think the same from CPAN.

The Apache Mobile Filter allows you to access WURFL from any programming language, not just Java and php that is traditionally used for dynamic mobile web sites.

The module detects the mobile device and passes the WURFL capabilities on to the other web application as environment variables. It can also be used to resize images on the fly to adapt to the screen size of the mobile device.

Try it and let me know your opinion.

For more info: http://www.idelfuschini.it/it/apache-mobile-filter-v2x.html
Test Page: http://apachemobilefilter.nogoogle.it/php_test.php

rozer.binny
06-26-2011, 02:54 PM
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 Device

jscheuer1
06-26-2011, 04:35 PM
Detection is rather easy. As an example, this is how Slimbox 2.04 detects many of them:


/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)

It does them all at once in order to avoid them. Slimbox 2.04 doesn't work on them.

But you can see the keywords and test individually and branch if that's you're intention.

If you have a device/browser that's not represented, use a little script to find out what might be unique about its navigator.userAgent string:


alert(navigator.userAgent);

You can also go here:

http://www.useragentstring.com/pages/useragentstring.php

to find these strings for virtually any browser.