I am currently using the code below to check which version of iOS the user is working on, but he has a little problem, if there is a 3rd digit for the version, it does not add a period to it, so when I check it on the device under running iOS 9.0.1 returns 9.01, I was not able to figure out how to fix it below to add a period between the second and third digit. any help is appreciated :)
<body>
<button onclick="myFunction()">Detect</button>
<p id="demo"></p>
<script>
function myFunction(){
var iOS = parseFloat(
('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0,''])[1])
.replace('undefined', '3_2').replace('_', '.').replace('_', '')
) || false;
alert(iOS)
}
</script>
</body>
source
share