Total Pageviews

Sunday, June 23, 2013

Detect Browser in Javascript, User agent detection in Javascript

<script type="text/javascript">
 var ismobile = navigator.userAgent.match(/(alcatel) | (amoi) | (android) | (avantgo) | (blackberry) | (benq) | (cell) | (cricket) | (docomo) | (elaine) | (htc) | (iemobile) | (iPhone) | (ipad) | (ipaq) | (ipod) | (j2me) | (java) | (midp) | (mini) | (mmp) | (mobi) | (motorola) | (nec-) | (nokia) | (palm) | (panasonic) | (philips) | (phone) | (playbook) | (sagem) | (sharp) | (sie-) | (silk) | (smartphone) | (sony) | (symbian) | (t-mobile) | (telus) | (vodafone) | (wap) | (webos) | (wireless) | (xda) | (xoom) | (zte)/i);

 if(ismobile)
 {

// window.location = 'https://www.google.com.my';
 alert("You are using mobile");

 }
 else
 {

 // window.location = 'https://www.yahoo.com';
 alert("You are using system");


 }
</script>


Follow kvn_krishna on Twitter

No comments:

Post a Comment