zoukankan      html  css  js  c++  java
  • 判断移动端设备: navigator.userAgent.toLowerCase()

    function browserRedirect() {
       var _devices= navigator.userAgent.toLowerCase();
       var bIsIpad = _devices.match(/ipad/i) == "ipad";
       var bIsIphoneOs = _devices.match(/iphone os/i) == "iphone os";
       var bIsMidp = _devices.match(/midp/i) == "midp";
       var bIsUc7 = _devices.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
       var bIsUc = _devices.match(/ucweb/i) == "ucweb";
       var bIsAndroid = _devices.match(/android/i) == "android";
       var bIsCE = _devices.match(/windows ce/i) == "windows ce";
       var bIsWM = _devices.match(/windows mobile/i) == "windows mobile";
      if(bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
        console.log("您是手机登录");
      } else {  
        console.log("您是电脑登录");

      }
    }

     注:仅作为工作中需要笔记

  • 相关阅读:
    override与new的区别
    预处理指令关键字
    索引器
    可选参数与命名参数
    sealed关键字
    获取变量默认值
    is和as
    throw和throw ex的区别
    位操作
    unsafe关键字
  • 原文地址:https://www.cnblogs.com/dreamperson/p/10724592.html
Copyright © 2011-2022 走看看