Today to introduce you to use JS to judge the mobile phone client platform and system platform method:
<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."); /This is the Android platform under browser
}
if (/(Iphoneipadipodios)/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 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 micro-trust platform under the browser
}
$ (document). Ready (function () {
alert (navigator.platform);
Checkplatform ();
});
</script>
Note that the above code uses jquery. You need to load jquery to run it. Of course, you can delete the trigger function.
Here is not to do the PC-side operating system platform judgment, how to judge also the next method, such as using document.write (Navigator.platform), you can get the operating system platform. The Win32 will be displayed under the Win32, and the Win64 will be displayed under Win64.
Below the cloud Habitat Community Small series for everyone to add a few good functions
<script type= "Text/javascript" > var browser = {Versions:function () {var u = navigator.useragent, app = NA
Vigator.appversion; return {trident:u.indexof (' Trident ') >-1, Presto:u.indexof (' Presto ') >-1, webkit:u.indexof (' Applew Ebkit ') >-1, Gecko:u.indexof (' Gecko ') >-1 && u.indexof (' khtml ') = = 1, Mobile:!! U.match (/applewebkit.*mobile.*/) | | !! U.match (/applewebkit/), iOS:!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/), Android:u.indexof (' Android ') >-1 | | U.indexof (' Linux ') >-1, iphone:u.indexof (' IPhone ') >-1 | | U.indexof (' Mac ') >-1, ipad:u.indexof (' IPad ') >-1, webapp:u.indexof (' Safari ') = = 1, qqbrw:u.indexof (' Mqqbrowser ') >-1, weixin:u.indexof (' Micromessenger ') >-1, Uclowend:u.indexof (' UCWEB7. ') >-1, UC Special:u.indexof (' rv:1.2.3.4 ') >-1, ucweb:function () {try {return parsefloat U.match (/ucweb\d+\.\d +/GI). toString (). Match (/\d+\.\d+/). ToString ()) >= 8.2} catch (e) {if (U.indexof (' UC ') >-1) {return true;
else {return false;
}} (), Symbian:u.indexof (' Symbian ') >-1, Ucsb:u.indexof (' Firefox/1. ') >-1}; } ()} if (BROWSER.VERSIONS.QQBRW) {document.write ("QQ browser");} else {document.write ("other Browsers");} </script>
Pro-Test, very easy to use.