• <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
  • <th id="l3qpx"><progress id="l3qpx"></progress></th>
      <th id="l3qpx"></th>
      <dd id="l3qpx"><font id="l3qpx"></font></dd>
      <th id="l3qpx"></th>
      0712-2888027 189-8648-0214
      微信公眾號

      孝感風(fēng)信網(wǎng)絡(luò)科技有限公司微信公眾號

      當(dāng)前位置:主頁 > 技術(shù)支持 > Javascript/JQuery > JavaScript用于判斷平板/移動端等設(shè)備的源代碼

      JavaScript用于判斷平板/移動端等設(shè)備的源代碼

      時間:2017-03-19來源:風(fēng)信官網(wǎng) 點擊: 1094次
      JavaScript用于判斷平板/移動端等設(shè)備的源代碼,分享出來如有需要的朋友可以借鑒使用。
      
      function mobile_device_detect(url) {
          var thisOS = navigator.platform;
          var os = new Array("iPhone", "iPod", "iPad", "android", "Nokia", "SymbianOS", "Symbian", "Windows Phone", "Phone", "Linux armv71", "MAUI", "UNTRUSTED/1.0", "Windows CE", "BlackBerry", "IEMobile");
          for (var i = 0; i < os.length; i++) {
              if (thisOS.match(os[i])) {
                  window.location = url;
              }
      
          }
      
          //因為相當(dāng)部分的手機系統(tǒng)不知道信息,這里是做臨時性特殊辨認
          if (navigator.platform.indexOf('iPad') != -1) {
              window.location = url;
          }
          //做這一部分是因為Android手機的內(nèi)核也是Linux
          //但是navigator.platform顯示信息不盡相同情況繁多,因此從瀏覽器下手,即用navigator.appVersion信息做判斷
          var check = navigator.appVersion;
          if (check.match(/linux/i)) {
              //X11是UC瀏覽器的平臺 ,如果有其他特殊瀏覽器也可以附加上條件
              if (check.match(/mobile/i) || check.match(/X11/i)) {
                  window.location = url;
              }
          }
          if (check.indexOf('Windows Phone') > -1) {//winphone手機
              window.location = url;
          }
          //類in_array函數(shù)
          Array.prototype.in_array = function (e) {
              for (i = 0; i < this.length; i++) {
                  if (this[i] == e)
                      return true;
              }
              return false;
          }
      }
      mobile_device_detect("/mobile/");
      
      
      欄目列表
      推薦內(nèi)容
      熱點內(nèi)容
      展開
      欧美一区二区三区免费A级视频,亚洲精品中文字幕综合,动漫精品中文字幕无码第一页,1024亚洲国产综合 亚太影院 柯西贝尔-游戏赚网
    1. <b id="l3qpx"><abbr id="l3qpx"></abbr></b>
    2. <th id="l3qpx"><progress id="l3qpx"></progress></th>
        <th id="l3qpx"></th>
        <dd id="l3qpx"><font id="l3qpx"></font></dd>
        <th id="l3qpx"></th>