返回

移动端加载页面判断加载客户端

  区分ios or android - js脚本
-- cp

2017-08-21 10:19:29
var u = navigator.userAgent.toLowerCase(), app = navigator.appVersion;
var isAndroid = u.indexOf('android') > -1 || u.indexOf('linux') > -1;
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+mac os x/);
if (isiOS ==false){
isiOS = u.indexOf('iphone')>-1;
}
if (isiOS ==false){
isiOS = u.indexOf('ipad')>-1;
}
console.log("u:" + u);
console.log("app:" + app);
console.log("isAndroid:" + isAndroid);
console.log("isiOS:" + isiOS);

我想说: