gpt4 book ai didi

jquery - 使用 jquery 检查 android 版本是否 < 4.1

转载 作者:行者123 更新时间:2023-12-01 01:07:44 24 4
gpt4 key购买 nike

我正在尝试为不同的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');
}

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

非常感谢

最佳答案

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

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

来自here

关于jquery - 使用 jquery 检查 android 版本是否 < 4.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19033920/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com