js检测手机类型(android,ios,blackberry,windows等)
2013-10-11 10:20
447 查看
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/
相关文章推荐
- iOS7中NSArray的改变
- ios学习之 IOS6屏幕旋转详解(自动旋转、手动旋转、兼容IOS6之前系统)
- iOS7中NSArray的改变
- iOS - CoreData服务器数据返回是"<null>":
- iOS运动之检测加速度计的可用性
- iOS SDK:iOS调试技巧
- 使用Xcode和Instruments调试解决iOS内存泄露
- IOS7状态栏StatusBar官方标准适配方法
- iOS7: 如何获取不变的UDID
- iOS文件处理
- iOS归档存储数据
- iOS内存管理(二)
- iOS内存管理(一)
- IOS 关键字
- ios滚动视图(scrollView)
- IOS-TextField知多少【转自csdn】
- AudioStreamBasicDescription
- IOS Resolutions & Display Specifications
- IOS 开发之 CocoaPods讲解
- ios实现用户登录的保存密码功能