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

Read Images from a xlsx file using Apache POI

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

How to create mail message in FRC822 format