Js 判断当前系统为安卓还是iOS
Admin
2020-04-27 PM
5114℃
0条
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; // 安卓终端
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
console.log("Andriod");
window.location.href = 'cos1://open?type=10000&url=' + encodeURIComponent(window.location.href) // 尝试打开app
}
if (isIOS) {
console.log("iOS");
window.location.href = 'oushangcos1://openoscar?type=10000&url=' + encodeURIComponent(window.location.href)
}