Get device type on accessing your website

Find which device has accessed your website: See the javascript code below


function GetDeviceType(){
           if( navigator.userAgent.match(/Android/i) ||
              navigator.userAgent.match(/webOS/i) ||
              navigator.userAgent.match(/iPhone/i) ||
              navigator.userAgent.match(/iPod/i) ||
              navigator.userAgent.match(/BlackBerry/)
            ){
               alert('Device type is ::'+navigator.userAgent);
            }else if(navigator.userAgent.match(/Windows/)){
   alert(' Device type is :: Windows:::'+navigator.userAgent);
}else if(navigator.userAgent.match(/Linux/)){
   alert(' Device type is : Linux:::'+navigator.userAgent);
}else{
              alert(' Other Device:::'+navigator.userAgent);
}


 }

If somebody knows Jquery code for this, update this post or comment here.

Comments

Popular posts from this blog

Struts 2 - struts tag with boolean property

Android: where to run keytool command in android