Express Detection : Advanced Uses

Detection without Redirection using API v3

Legendary kung fu master Bruce Lee practiced the art of fighting without fighting. Similarly, you can tap this great power. Use it wisely.

Express Detection (our fancy name for javascript device detection) happens in two parts. Each detection dynamically generates javascript which gets sent to the device with the detection results embedded in the script. The device reads the script and performs a redirection based on rules setup insite the site’s settings on Handset Detection.

By creating a site with no redirection rules the script acts as just a detector. You can then access the detection results directly from javascript.

Note: You’ll need to make sure the script has loaded before accessing the object. The Basic Detector () makes this easy, or rig up something to execute after the script has been loaded.

The examples below contain the results for an iPhone detection and a standard desktop browser (or a mobile after the detection quota has been reached). Access the variables via HandsetDetection.ismobile, HandsetDetection.os, HandsetDetection.hdclass etc …

iPhone Results

// Handset Detection mobile redirection script 1.3
// iPhone device
var HandsetDetection = {
    ismobile : true,
    istablet : false,
    isconsole : false,
    xhtmllevel : 4,
    width : 320,
    height : 480,
    formfactor : "bar",
    hdclass : "mobile",
    vendor : "apple",
    model : "iphone",
    os : "ios",
    osversion : "3.0",
    browser : "mobile safari", 
    browserversion : "4.0",
    urls : ["www.starport.net","m.starport.net?$query$&os=$os$&model=$model$","t.starport.net?$query$&os=$os$&model=$model$","www.jones.com"],
    country : "au",
    city : "melbourne",
    region : "victoria",
    isp : "iinet limited",
    company : "iinet limited",

    // Redirect function removed
}

Standard Desktop Results

// Handset Detection mobile redirection script 1.3
// Standard desktop device
var HandsetDetection = {
    ismobile : false,
    istablet : false,
    isconsole : false,
    xhtmllevel : 0,
    width : 0,
    height : 0,
    formfactor : "unknown",
    hdclass : "",
    vendor : "",
    model : "", 
    os : "",
    osversion : "",
    browser : "", 
    browserversion : "",
    urls : ["www.starport.net","m.starport.net?$query$&os=$os$&model=$model$","t.starport.net?$query$&os=$os$&model=$model$","www.jones.com"],
    country : "au",
    city : "melbourne",
    region : "victoria",
    isp : "iinet limited",
    company : "iinet limited",
        
    // redirect function removed 
}

Note : Take care using width and height. They’re designed to be used in conjunction with an ismobile, istablet or isconsole test. As you can see, they’re always 0 on undetected devices. So if you’re checking HandsetDetection.width make sure to check HandsetDetection.ismobile as well.

Manual Override !

There is a few advanced edge cases where you might want to force disable redirection. Here’s how to do it.

1) Check the Manual Override box on your site profile. 2) Append &expressredirect=false to your URL.

Job Done ! That was easy. :)

Get Started Today

Our free Express / Cloud plan has 20,000 detections per month. No credit card required. Upgrade when you're ready. We also have a free Community Edition for Ultimate Detection, our high performance local detection library, which you can build into community open source projects.


Get Started. Its Free