0

I am building a webservice using Python at back-end and Front end as HTML, JS, Ajax etc. My webservice has a particular need that it has two different kind of response for those visiting using Android device or iPhone or other devices (PC, Mac etc).

I want to register users (on my website) based on their device type and Assign a particular UId to each device.

So is it possible to detect Device type which is visiting my website and let them access services according to their device type?

Any JavaScript or jQuery way possible?

Please suggest.

CracLock
  • 593
  • 3
  • 7
  • 26

1 Answers1

0

This is the javascript way of detecting android

var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
    // Do something!
    // Redirect to Android-site?
    window.location = 'http://android.davidwalsh.name';
}

This is the javascript way of detecting IPhone

if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
     if (document.cookie.indexOf("iphone_redirect=false") == -1) window.location = "http://m.espn.go.com/wireless/?iphone&i=COMR";
}

both methods are taken from http://davidwalsh.name/

PurityLake
  • 1,030
  • 9
  • 18