This is related to the "fix" for position:fixed in older versions of iOS. However, if iOS5 or greater is installed, the fix breaks the page.
I know how to detect iOS 5: navigator.userAgent.match(/OS 5_\d like Mac OS X/i)
but that won't work for iOS6 when it eventually comes around, or even iOS 5.0.1, only a 2 digit version.
So this is what I have atm.
$(document).bind("scroll", function() {
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
if (navigator.userAgent.match(/OS 5_\d like Mac OS X/i)) {
}
else {
changeFooterPosition();
}
});
Just simply run this code in device/browser
This iphone_version variable will give you correct OS version for any iPhone device.
Pumbaa80's Answer was almost 100%, he just left out one part. Some iOS release have a third digit on them.
Example
The follow allows for that
That extra bit (_\d)? allows for the possibility of a third digit in the Version number. Charlie S, That should answer your question too.
Note the else because the 1st check won't work on iOS 1. iOS 1 for the iPhone and iPod didn't include a version number in its UserAgent string.
iPhone v 1.0
iPod v1.1.3
All of this can be found at the following link on Apples website here.
I could not really find what I was looking for, so I took ideas from this page and other pages around the net and came up with this. Hopefully others will find it useful as well.
It allows you to get the major release and full release number either as a string or as a number for iOS.
Example User Agent String:
Usage:
In the case of the original question on this page, you could use this code in the following manner:
This snippet of code can be used to determine any version of iOS 2.0 and later.
This will return an array with the individual version numbers like
[10,0,1]
for v10.0.1, or it'll default to[0]
otherwise. You can check the first digit (the major version) or all of them to test for the versions you need.First: Don't use
match
when atest
is enough.Second: You should test the other way round. Find the UAs which are known to be broken.