Mobile Detect Script

Number of Views : 3039

Mobile Detection

Mobile Detection Script

In the past year I have developed a few mobile websites. These normally consist of a specific mobile view (jquerymobile) or a responsive design. In the case of a specific mobile view, you need some type of mechanism to detect the type of browser that is viewing the site. Because of the ever increasing mobile browsers and devices this is a tricky process. A few sites I created over 2 years ago do not register newer devices (kindle fire, newer androids, etc…)

I recently have decided to use MobileESP as the process to detect and interrogate what type of browser is viewing the site.

MobileESP has a few great options that I believe make it the best option.

First, they have multiple versions available. A real-time API and also a downloadable version. The realtime API takes into account the ever changing mobile landscape. This option would allow the developer to just have to focus on the action needed with a mobile or tablet like device and not worry about maintaining the list of devices.

MobileESP API info

Second, the downloadable version includes multiple languages. Ranging from Javascript, java, php, .net, python, and Ruby (even classic asp). Often I find myself writing code in different languages. MobileESP allows the option for each major language (NOTE: I think of these as the major languages on the web).

In most cases I enjoy using the javascript version. The project I just completed I used the function DetectMobileQuick() – Detects if the current device is a mobile device. This method catches most of the popular modern devices. Excludes Apple iPads and other modern tablets. This allowed me to just have the mobile devices see the jquerymobile site and have the tablets hit the full site. See the code snip below.

 if (DetectMobileQuick()){
        window.location = "http://www.somemobilesite/m";
}

Here is the About info for the mobileESP project. The code is hosted on code.google.com

The MobileESP project seeks to provide web site developers an easy-to-use and lightweight API for detecting whether visitors are using a mobile device, and if so, what kind. The APIs provide simple boolean results (“true” or “false”) for identifying individual device categories (such as iPhone, BlackBerry, Android, and Windows Mobile), device capabilities (e.g., J2ME), and broad classes of devices, such as “iPhone Tier” (iPhone/Android/WebOS) and smartphones.

I would like to thank the great team who maintains and updates this project.

Leave a Reply

Your email address will not be published. Required fields are marked *