1. js to determine the iOS version number
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/8H7 Safari/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/8H7 Safari/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/8H7 Safari/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]* like Mac OS x/i);
} else {
return false;
}
}
2, JS judge the mobile browser operating system and browser methods
To do the front-end development of mobile phone, but the mobile phone platform to judge. For app downloads, see Android download prompts on Android, and iOS download tips under iOS.
Today, we introduce the method of using JS to judge the mobile client platform and system platform:
<script type= "Text/javascript" >//mobile phone side to determine the platform browser and operating system platform function Checkplatform () {if (/android/i.test ( navigator.useragent)) {document.write ("This is Android ' browser."); /It is Android platform under browser}if (/(Iphone|ipad|ipod|ios)/i.test (navigator.useragent)) {document.write ("This is IOS ' browser."); /This is the iOS platform under browser}if (/linux/i.test (navigator.useragent)) {document.write ("This is Linux ' browser."); /This is the Linux platform under browser}if (/linux/i.test (navigator.platform)) {document.write ("This is the Linux operating system."); /This is the Linux operating system platform}if (/micromessenger/i.test (navigator.useragent)) {document.write ("This is Micromessenger ' browser."); /This is the platform under browser}} $ (document). Ready (function () { alert (navigator.platform); Checkplatform (); }); </script>
In here do not do PC-side operating system platform judgment, how to judge also next method, such as with document.write (Navigator.platform), you can get the operating system platform. The Win32 will be displayed under the Win32, and WIN64 will be displayed under Win64.
JS get phone model and mobile OS version number