JS judge the mobile browser operating system and micro-browser methods _javascript skills

Source: Internet
Author: User
Tags win32

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.

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.