The UA and Urlschema of JavaScript

Source: Internet
Author: User

We first get the browser UA:

1 var ua = navigator.useragent;
1 if (Ua.indexof ("Micromessenger") >-1) {2         alert ("browser"); 3     
1 if (Ua.indexof ("iphone") >-1) {2         alert ("iphone");   3     }

Other browsers and mobile browsers have their own UA, we can find it in the middle of a keyword to judge it, do not list down, on the internet can be checked, here only to explain the method of determination.

We use the UA to determine which mobile device a visitor uses to make a request for a page, which can be done using urlschema, location.href = "appiphone://", which can drop the corresponding app in the iphone. The premise is that this appiphone is registered in the app we've developed, so it can evoke the client.

Then we can determine whether the app is activated by judging the visibility status of the browser page, or if it is not activated, we can continue to work on the page, or let the program visit the store to download the app.

1 if (Ua.indexof ("IPhone") >-1) {2     location.href = "appiphone://"; 3     Window.settimeout (function() {4     iffalse) { 5     Location.href = "http://itunes.apple.com/cn/app/"; 6     }7 }, (); 8

JavaScript ua and Urlschema

Related Article

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.