var isMobile = {    Android: function() {        return navigator.userAgent.match(/Android/i);    },    BlackBerry: function() {        return navigator.userAgent.match(/BlackBerry/i);    },    iOS: function() {        return navigator.userAgent.match(/iPhone|iPad|iPod/i);    },    Opera: function() {        return navigator.userAgent.match(/Opera Mini/i);    },    Windows: function() {        return navigator.userAgent.match(/IEMobile/i);    },    any: function() {        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());    }};

  

EXAMPLES

To check to see if the user is on any of the supported mobile devices:

if( isMobile.any() ) alert('Mobile');

To check to see if the user is on a specific mobile device:

if( isMobile.iOS() ) alert('iOS');

原文:http://www.abeautifulsite.net/blog/2011/11/detecting-mobile-devices-with-javascript/

更多相关文章

  1. Android Fresco图片处理库用法API英文原文文档4(Facebook开源Andr

随机推荐

  1. Android:复杂数据模型的传递
  2. 微服务-Android客户端: 实现注册和登录
  3. 浅析Android(安卓)MediaProvider之二
  4. Android实现录屏直播(三)MediaProjection +
  5. 【Android(安卓)开发】:UI控件之 ScrollVi
  6. android Activity线性布局和表格布局实例
  7. 如何检查 Android 应用的内存使用情况
  8. Android学习路线:如何成长为高级工程师
  9. APP开发 你应该iOS和Android都开发 还是
  10. Android面试宝典----1.选择填空分析及答