According to UserAgent, is the mobile end iOS or Android?

Source: Internet
Author: User

The user agent Chinese name is the users proxy, is part of the HTTP protocol, is part of the header domain, the user agent is also referred to as UA. It is a special string header that provides access to the Web site with information such as the type and version of the browser you are using, the operating system and version, the browser kernel, and so on.

Through this logo, users visit the site can display a different layout to provide users with better experience or information statistics, such as mobile phone access to Google and computer access is not the same, these are Google according to the visitor's UA to judge. The UA can also be disguised.

  

1 functionIsipad (useragent) {2     return(Useragent.indexof ("IPad") >-1);3 }4 functionIsiphone (useragent) {5     return(Useragent.indexof ("IPhone") >-1);6 }7 functionIsios (useragent) {8     returnIsipad (useragent) | |Isiphone (useragent);9 }Ten functionisandroid (useragent) { One     return(Useragent.indexof ("Android") >-1) | | A(Useragent.indexof ("Linux") >-1); -}

The UserAgent property of the Navigator object is called by the BOM, and the device type of the mobile client can be judged based on the obtained Mobios.

Encapsulated code slices:

  

1 // User agent string from navigator 2 var useragent = navigator.useragent; 3 4 // Name of Mobile OS 5 var mobios = isandroid (useragent)? "Android" :6     (Isios (useragent)? "ios": "Unknow");

According to UserAgent, is the mobile end iOS or Android?

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.