Displaying Detection Results in Pages

Its super easy to display handset information, or any detection information, in web pages. 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 inside the site’s settings on Handset Detection.
By creating a site with no redirection rules the script acts as just a detector, and you can grab the detected information. Then access the detection results directly from javascript.
The Basic Detector makes this easy.
Step 1) Place the basic detector script in your web page. Something like this
<script type=’text/javascript’ src=’http://api.handsetdetection.com/sites/js/[your-site-id].js'></script>
Step 2) Access the hdRequestInfo object. The examples below contain the results for a Google Nexus 7 detection and a standard desktop browser (or a mobile after the detection quota has been reached).
Access the variables via hdRequestInfo.ismobile, hdRequestInfo.os, hdRequestInfo.hdclass etc … The full list of variables are below.
Google Nexus 7
var hdRequestInfo = {
  ismobile : false,
  istablet : true,
  isconsole : false,
  width : 1920,
  height : 1200,
  formfactor : "tablet",
  hdclass : "tablet",
  vendor : "google",
  model : "nexus 7", 
  os : "android",
  osversion : "4.3",
  browser : "android chrome", 
  browserversion : "42.0",
  urls : ["www.starport.net","m.starport.net","t.starport.net","www.jones.com"],
  country : "au",
  city : "caloundra",
  region : "queensland",
  isp : "optus",
  company : "optus wireless",
  sid : "5607d295370e760b4003c598",
  internalreferrer : 0,
  displaysize : 7,
  aliases : "",
  ppi : 323,
  features : "Unlimited entries,Calendar,Alarm,Document viewer,Calculator,IMAP,POP3,SMTP,Microsoft Exchange,Email,Google Talk,Mass storage device,USB charging,Computer sync,OTA sync,Music ringtones (MP3),Polyphonic ringtones,Vibration,Flight mode,Silent mode,Speakerphone,Accelerometer,Gyroscope,CompassVoice commands,Voice recording,Light sensor,Proximity sensor,Scratch-resistant glass,Games,Qi Integrated",
  connectors : "USB 2.0,MicroUSB,3.5mm Audio"
}
Apple OS X Laptop
// Script version 4.14
var hdRequestInfo = {
  ismobile : false,
  istablet : false,
  isconsole : false,
  width : 1280,
  height : 800,
  formfactor : "varies",
  hdclass : "computer",
  vendor : "generic",
  model : "os x pc", 
  os : "os x",
  osversion : "10.10",
  browser : "chrome", 
  browserversion : "",
  urls : ["www.starport.net","m.starport.net","t.starport.net","www.jones.com"],
  country : "au",
  city : "caloundra",
  region : "queensland",
  isp : "optus",
  company : "optus wireless",
  sid : "5607d33f370e76897203ca5b",
  internalreferrer : 0,
  displaysize : 13.3,
  aliases : "",
  ppi : 113,
  features : "",
  connectors : ""
}
Take care using Width and Height variables. Devices without screens may have these variables to 0.

Still need help? Contact Us Contact Us