我正在尝试为不同的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/