js判断设备是否是移动端代码
2016-06-06 00:00
531 查看
移动端设备判断,简短够用
移动端设备判断仍然简短判断的也挺全
js判断手机移动设备是Android平台还是ios平台
[code=language-javascript]var isWebkit = /Webkit/i.test(navigator.userAgent), isChrome = /Chrome/i.test(navigator.userAgent), isMobile = !!("ontouchstart" in window), isAndroid = /Android/i.test(navigator.userAgent), isIE = document.documentMode;
移动端设备判断仍然简短判断的也挺全
[code=language-javascript]<script type="text/javascript"> function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; document.writeln("您的浏览设备为:"); if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { document.writeln("phone"); } else { document.writeln("pc"); } } browserRedirect(); </script>
js判断手机移动设备是Android平台还是ios平台
[code=language-javascript]if (/android/i.test(navigator.userAgent)){ // todo : android } if (/ipad|iphone|mac/i.test(navigator.userAgent)){ // todo : ios }
相关文章推荐
- Objective-C ---UIImageView (梳理整理)
- Android中AsyncTask的简单用法
- 使用 Android Studio自定义View04——视频音量调控
- 微信Oauth2.0以及jssdk签名
- iOS版本更新的App提交审核流程
- 下载微信支付sdk的两个方法
- Android四角圆形背景
- Android 屏幕分辨率工具类使用
- 使用服务注册广播接收者
- Retrofit 泛型解析遇到com.google.gson.internal.LinkedTreeMap cannot be cast to object
- geekband android #5 第十四周分享(设计模式)
- 浅谈AndroidTV开发与常规APP开发的异同点
- iOS 动画初步
- iOS多线程编程--GCD
- Android studio 代码收缩设置
- PhoneNumberUtils用法学习
- Android使用SO库时要注意的一些问题
- swift之方法(Methods)
- Android_Handler
- EventBus3.0使用初体验