zoukankan      html  css  js  c++  java
  • js判断设备(转)

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>js判断设备类型是移动设备还是PC设备</title>
      <script type="text/javascript">
        // borwserRedirect
        (function browserRedirect(){
          var sUserAgent = navigator.userAgent.toLowerCase();
          var bIsIpad = sUserAgent.match(/ipad/i) == 'ipad';
          var bIsIphone = sUserAgent.match(/iphone os/i) == 'iphone os';
          var bIsMidp = sUserAgent.match(/midp/i) == 'midp';
          var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == 'rv:1.2.3.4';
          var bIsUc = sUserAgent.match(/ucweb/i) == 'web';
          var bIsCE = sUserAgent.match(/windows ce/i) == 'windows ce';
          var bIsWM = sUserAgent.match(/windows mobile/i) == 'windows mobile';
    
          if(bIsIpad || bIsIphone || bIsMidp || bIsUc7 || bIsUc || bIsCE || bIsWM){
            window.location.href = 'http://www.163.com/';
          }else{
            window.location.href = 'http://www.baidu.com/';
          }
        })();
      </script>
    </head>
    <body>
      <h1>pc浏览</h1>
    </body>
    </html>
  • 相关阅读:
    硬件_WIFI&Blue
    C++_练习—多态_纯虚函数与抽象类
    C++_练习—多态_验证vptr分布初始化
    C++_练习—多态_证明vptr指针的存在
    单摆方程
    谐振动相关知识
    UVa 129
    LeetCode-316
    Java 运算符
    一些特殊的矩阵
  • 原文地址:https://www.cnblogs.com/limit1/p/4688288.html
Copyright © 2011-2022 走看看