【问题标题】:check if android version < 4.1 with jquery使用 jquery 检查 android 版本是否 < 4.1
【发布时间】:2013-10-02 18:10:00
【问题描述】:

我正在尝试为不同的 android 版本应用功能。我的代码是:

var deviceAgent = navigator.userAgent.toLowerCase();
    var agentID = deviceAgent.match(/(Android)/i);
    if (agentID) {
        var androidversion = parseFloat(agentID.slice(agentID.indexOf("Android")+8));
       if (androidversion < 4.1)
        {
           alert(agentID + androidversion + 'I am older than JB');
             newsblocks(); 
        } else {
           alert(agentID + androidversion + 'I am JB and up');
        }
        } else {
      alert('I am not android');
    }

但由于某些原因,这段代码不起作用,无论安卓版本如何读取它都会显示“我是 JB 及以上”。你能帮我解决这个问题吗?

非常感谢

【问题讨论】:

  • 不能用特征检测吗?为什么特别喜欢 JellyBean?
  • 我在 4.0.4 上遇到了一个插件问题(屏幕上的 swiper 跳转)。虽然它在 4.1 上运行良好

标签: jquery


【解决方案1】:

var agentID = deviceAgent.match(/Android\s+([\d\.]+)/)[1]

例如:http://jsfiddle.net/DZEYk/1/http://jsfiddle.net/DZEYk/3/

来自here

【讨论】:

  • 嗨,克里斯蒂,快到了,但我的台词:如果(版本
猜你喜欢
  • 2013-10-02
  • 1970-01-01
  • 1970-01-01
  • 2012-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-23
  • 2021-12-29
相关资源
最近更新 更多