JavaScript determines the iOS version number

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.