判断终端是pc还是mobile,返回值为number,0为pc,1为mobile,pc&mobile
2017-07-22 11:48
267 查看
/*判断终端是pc还是mobile,返回值为number,0为pc,1为mobile,pc&mobile*/
function isPcOrMobile(){ var motionType = 0; 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"; if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { motionType = 1; } return motionType; }
相关文章推荐
- wordpress 判断浏览终端是 pc 还是 mobile 模式 使用插件 Any Mobile Theme Switcher
- Javascript自定义函数判断网站访问类型是PC还是移动终端
- 如何判断移动终端访问还是PC访问?
- JS判断浏览器是PC还是Mobile访问
- 判断设备终端是pc还是移动端
- 判断终端是手机还是PC
- web PHP判断请求来自PC还是Mobile
- JS判断是PC还是移动端浏览器,并根据不同的终端跳转到不同的网址
- 随笔-判断是否是PC,还是mobile访问
- JS判断PC终端还是移动终端来跳转不同的路径
- 判断ip是内网还是外网, 判断请求来之pc还是mobile
- 判断访问终端是手机还是PC
- js判断pc还是mobile访问
- Javascript自定义函数判断网站访问类型是PC还是移动终端
- //判断当前是PC终端还是移动终端来跳转不同的路径
- PHP判断PC还是手机登录
- JS 判断访问终端是电脑还是移动设备/手机
- js原生判断浏览器是移动还是PC
- uaredirect.js 进行判断是pc还是wap端(移动端) wap端跳转页面
- js判断用户的浏览设备是移动设备还是PC