zoukankan      html  css  js  c++  java
  • 终端判断

      function detect(ua){
        var os = this.os = {}, browser = this.browser = {},
          webkit = ua.match(/WebKit/([d.]+)/),
          android = ua.match(/(Android)s+([d.]+)/),
          ipad = ua.match(/(iPad).*OSs([d_]+)/),
          iphone = !ipad && ua.match(/(iPhonesOS)s([d_]+)/),
          webos = ua.match(/(webOS|hpwOS)[s/]([d.]+)/),
          touchpad = webos && ua.match(/TouchPad/),
          kindle = ua.match(/Kindle/([d.]+)/),
          silk = ua.match(/Silk/([d._]+)/),
          blackberry = ua.match(/(BlackBerry).*Version/([d.]+)/)
    
        // todo clean this up with a better OS/browser
        // separation. we need to discern between multiple
        // browsers on android, and decide if kindle fire in
        // silk mode is android or not
    
        if (browser.webkit = !!webkit) browser.version = webkit[1]
    
        if (android) os.android = true, os.version = android[2]
        if (iphone) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.')
        if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.')
        if (webos) os.webos = true, os.version = webos[2]
        if (touchpad) os.touchpad = true
        if (blackberry) os.blackberry = true, os.version = blackberry[2]
        if (kindle) os.kindle = true, os.version = kindle[1]
        if (silk) browser.silk = true, browser.version = silk[1]
        if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true
      }

    zepto 里的终端判断

  • 相关阅读:
    c++<ctime>中常用函数
    头文件<cmath>中常用函数
    c++动态数组的使用
    迭代器与指针
    引用和指针做形参时的区别
    c++使用cin、cout与c中使用scanf、printf进行输入输出的效率问题
    c++指定输出小数的精度
    Linux命令学习(1)
    Nginx 配置文件nginx.conf中文详解
    Walle实现自动发布
  • 原文地址:https://www.cnblogs.com/rainbow661314/p/4760977.html
Copyright © 2011-2022 走看看