Automatic judgment of mobile terminal equipment via JS (ios\android, etc.)

Source: Internet
Author: User

When the user scans a QR code with a mobile device, it links the scanned link to a page that contains only the JS that determines the mobile terminal, and automatically jumps to the corresponding link or downloads the corresponding content after judging it.

The HTML code is as follows:

1 <Script>2 varBrowser= {3 Versions:function() {4         varu=navigator.useragent, App=navigator.appversion;5         return {//Mobile Terminal browser version information6 Trident:u.indexof ('Trident') > -1, //IE kernel7 Presto:u.indexof ('Presto') > -1, //Opera Kernel8 Webkit:u.indexof ('AppleWebKit') > -1, //Apple, Google kernel9 Gecko:u.indexof ('Gecko') > -1 &&U.indexof ('khtml') == -1, //Firefox kernelTen Mobile:!!U.match (/applewebkit.*mobile.*/) || !!U.match (/AppleWebKit/), //whether it is a mobile terminal One iOS:!!U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS X/), //iOS terminal A Android:u.indexof ('Android') > -1 ||U.indexof ('Linux') > -1, //Android Terminal or UC browser - Iphone:u.indexof ('IPhone') > -1 ||U.indexof ('Mac') > -1, //whether it's an iphone or Qqhd browser - Ipad:u.indexof ('IPad') > -1, //whether ipad the Webapp:u.indexof ('Safari') == -1 //whether the web should program, no head with the bottom -         }; -     }(), - language: (Navigator.browserlanguage||navigator.language). toLowerCase () + } -  + if(Browser.versions.ios||Browser.versions.iPhone||browser.versions.iPad) { A window.location="https://itunes.apple.com/us/app/hua-nan-cheng-guang-shi-chang/id900382780?l=zh&ls=1&mt=8"; at } - Else if(browser.versions.android) { - window.location="http://guangapk.csc86.com:8100/csc_guang.apk"; - } - /*Document.writeln ("language version:" + browser.language); - Document.writeln ("Whether for Mobile Terminal:" + browser.versions.mobile); in Document.writeln ("iOS terminal:" + Browser.versions.ios); - Document.writeln ("Android Terminal:" + browser.versions.android); to Document.writeln ("Whether for IPhone:" + browser.versions.iPhone); + Document.writeln ("Whether IPad:" + browser.versions.iPad); - Document.writeln (navigator.useragent);*/ the </Script>

This article reprinted to: Http://www.cnblogs.com/pengxl/p/3476588.html

Automatic judgment of mobile terminal equipment via JS (ios\android, etc.)

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.