js判断当前是什么设备
js判断当前是什么设备
/** * 判断当前是什么设备 * @returns {string} */ getIsApps: function() { var u = navigator.userAgent; var ua = navigator.userAgent.toLowerCase(); var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); var isHsApp = (u.indexOf("_hsApp_") != -1) || (u.indexOf("entApp") != -1); var isHsEntApp = u.indexOf("entApp") != -1; var isWeixin = ua.indexOf('micromessenger') != -1; var isAliPay = ua.indexOf('alipayclient') != -1; var isWeb = !isHsApp && !isWeixin && !isAliPay; var obj = { isHsApp: isHsApp, //互生App终端 isHsEntApp: isHsEntApp, //互生企业App终端 isAndroid: isAndroid, //android终端 isiOS: isiOS, //ios终端 isWeixin: isWeixin, //微信终端 isAliPay: isAliPay, //支付宝终端 isWeb: isWeb, //浏览器终端 } return obj; },