Results 1 to 7 of 7

Thread: Mobile Browser Detection

  1. #1
    Join Date
    Jul 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Mobile Browser Detection

    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?:
    Code:
    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,944
    Thanks
    43
    Thanked 3,193 Times in 3,156 Posts
    Blog Entries
    12

    Default

    I'm not sure if this would work, but it is worth a shot. If it works, it should detect all mobiles:

    Code:
    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/
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2007
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,944
    Thanks
    43
    Thanked 3,193 Times in 3,156 Posts
    Blog Entries
    12

    Default

    You can probably Google that information, for example:

    http://na.blackberry.com/eng/develop...js.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/tutoria...s/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&c...ct&btnG=Search
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Apache Mobile Filter

    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...ilter-v2x.html
    Test Page: http://apachemobilefilter.nogoogle.it/php_test.php

  6. #6
    Join Date
    Jun 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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
    Last edited by jscheuer1; 06-26-2011 at 04:13 PM. Reason: self promotion violation

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,944
    Thanks
    43
    Thanked 3,193 Times in 3,156 Posts
    Blog Entries
    12

    Default

    Detection is rather easy. As an example, this is how Slimbox 2.04 detects many of them:

    Code:
    /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:

    Code:
    alert(navigator.userAgent);
    You can also go here:

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

    to find these strings for virtually any browser.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •