• <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
      微信公眾號(hào)

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

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

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

      時(shí)間:2017-03-19來(lái)源:風(fēng)信官網(wǎng) 點(diǎn)擊: 1094次
      JavaScript用于判斷平板/移動(dòng)端等設(shè)備的源代碼,分享出來(lái)如有需要的朋友可以借鑒使用。
      
      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;
              }
      
          }
      
          //因?yàn)橄喈?dāng)部分的手機(jī)系統(tǒng)不知道信息,這里是做臨時(shí)性特殊辨認(rèn)
          if (navigator.platform.indexOf('iPad') != -1) {
              window.location = url;
          }
          //做這一部分是因?yàn)锳ndroid手機(jī)的內(nèi)核也是Linux
          //但是navigator.platform顯示信息不盡相同情況繁多,因此從瀏覽器下手,即用navigator.appVersion信息做判斷
          var check = navigator.appVersion;
          if (check.match(/linux/i)) {
              //X11是UC瀏覽器的平臺(tái) ,如果有其他特殊瀏覽器也可以附加上條件
              if (check.match(/mobile/i) || check.match(/X11/i)) {
                  window.location = url;
              }
          }
          if (check.indexOf('Windows Phone') > -1) {//winphone手機(jī)
              window.location = url;
          }
          //類(lèi)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)容
      熱點(diǎn)內(nèi)容
      展開(kā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>