JS 判断用户设备是IOS 还是 Android

版权声明:JiahaoZhang原创文章,转载请注明出处 https://blog.csdn.net/GrootBaby/article/details/88031238
$(function () {
    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
    var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isAndroid) {
        alert("安卓机!")
    }
    if (isIOS) {
        alert("苹果果机!")
    }
});

猜你喜欢

转载自blog.csdn.net/GrootBaby/article/details/88031238