I am trying to apply functions for different android versions. My code is:
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');
}
But for some reasons this code doesn't work and whatever version of android reads it it shows 'I am JB and up'. Can you please help me with this issue?
Thanks a lot