First look at the user-agent string for IOS:
IPhone 4.3.2 System:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us)AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7Safari/6533.18.5
Ipone 5.1 System:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1 like Mac OS X; en-us)AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7Safari/6533.18.5
Ipone 5.1.1 System:
Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en-us)AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7Safari/6533.18.5
We can find some rules from User-agent: all contain "iPhone" keywords; contains the system version number separated by an underscore. Well, we can use these two laws to distinguish the system above iOS4.
function Gt_ios4 () {
Determine if iphone or IPod
if ((Navigator.userAgent.match (/iphone/i) | | | Navigator.userAgent.match (/ipod/i))) {
Determine if the system version number is greater than 4
Return Boolean (Navigator.userAgent.match (/os [5-9]_\d[_\d]* likemac OS x/i);
} else{
return false;
}
}
Reprint Address: http://blog.sina.com.cn/s/blog_56e3129d0101l2xx.html
JavaScript determines the iOS version number