App与Js交互(三)Android、iOS通用解决方案推荐

https://www.jianshu.com/p/6224f429ce87

window.navigator.userAgent用来区分设备和浏览器

https://blog.csdn.net/liangyihe/article/details/78464656

window.navigator.userAgent.toLowerCase()用来区分设备和浏览器


var sUserAgent = window.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) {
window.location.href = "WapUI/Main.html";
}
else {
window.location.href = "WebUI/Main.html";
}

————————————————
版权声明:本文为CSDN博主「liangyihe」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/liangyihe/article/details/78464656

navigator.userAgent.match(/(iPhone|iPod|Android|ios)/i)) 判断是不是 移动设备 'ontouchstart' in window; 判断支不支

猜你喜欢

转载自www.cnblogs.com/sundaysme/p/11951780.html