Aug.19

Detecting Android, iPhone, iPod, iPad and BlackBerry browser with JavaScript

var ua = navigator.userAgent.toLowerCase();
var ua_checker = {
  android: ua.match(/android/),
  iphone: ua.match(/(iphone|ipod|ipad)/),
  blackberry: ua.match(/blackberry/)
};
if (ua_checker.android) {
  // up to you
}
else if (ua_checker.iphone) {
  // up to you
}
else if (ua_checker.blackberry) {
  // up to you
}

Comments

comments

Web Programming
Share this Story:
  • facebook
  • twitter
  • gplus

About admin