Javascript判断浏览器终端是安卓Android还是苹果iOS

   // get the type of client
    judgeClient() {
      let u = navigator.userAgent;
      let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //判断是否是 android终端
      let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //判断是否是 iOS终端

      if (isAndroid) {
        console.log("Android")
      } else if (isIOS) {
        console.log("iOS")
      } else {
        console.log("其它")
      }
    },

 

你可能感兴趣的:(JavaScript)