JavaScript access to mainstream phone systems and models

Source: Internet
Author: User

<script src= "Http://cdn.bootcss.com/jquery/3.3.1/jquery.min.js" ></script><script src= "/http Cdnjs.cloudflare.com/ajax/libs/mobile-detect/1.4.1/mobile-detect.min.js "></script><script>//determines whether a string is contained in an arrayArray.prototype.contains =function(needle) { for(Iinch  This) {              if( This[I].indexof (needle) > 0)                  returni; }          return-1; }        varDevice_type = navigator.useragent;//Get useragent Information    varMD =NewMobiledetect (Device_type);//Initialize Mobile-detect    varOS = Md.os ();//Get System    varModel = ""; if(OS = = "IOS") {//handling of iOS systemsOS = Md.os () + md.version ("IPhone"); Model=Md.mobile (); } Else if(OS = = "Androidos") {//processing of the Android systemOS = Md.os () + md.version ("Android"); varSSS = Device_type.split (";"); vari = Sss.contains ("build/"); if(I >-1) {model= sss[i].substring (0, Sss[i].indexof ("build/"))); }      } Else{OS= ' non-mainstream OS '; Model= ' UnKnown '; } document.write (Operating system: "+ OS +" <br/> Model: "+ model");//Print to Page</script>

Open the page with your phone the results are as follows:

Reference: https://github.com/hgoebl/mobile-detect.js/

JavaScript access to mainstream phone systems and models

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.