HTML5 page JS to determine whether to install the app, and to determine whether to open the HTML5 page inside the app

Source: Internet
Author: User

One HTML5 page JS to determine whether to install the appAt present, the browser can not directly determine whether to install the app through Google to refer to other people's way and test we know that an app installed through the scheme Jump Protocol (referral: http://www.jianshu.com/p/eed01a661186) Access to the app is not installed when the click on the link is not valid, so by clicking on the link to the implementation of the time difference between the app to determine whether to install the App 1, the following is only processedAndroid System  
     if(Navigator.userAgent.match (/android/i)) {varNowtime =NewDate (). ValueOf (); SetTimeout (function() {varLaunchtime =NewDate (). ValueOf ()-Nowtime; if(Launchtime < 28) {//28 is the time it takes to debug an estimated open local app .window.location = "/phone/forward/app_download_redirect";//Download the app page}},25); Window.location= "mysppscheme://";//self-defined scheme protocol}
2.iphoneUse the same principle to achieve the test effective 3,WeixinSharing the page in the URL add variable isappinstalled isappinstalled=1 when the app is installed, the value of 0 is not installed blocked URL Scheme direct jump, so weixin share page by prompting the browser to open Then determine if the app is installed based on the previous isappubstalled value.
var // whether in var // whether to install the app
The above way is I through Google to see the way you put forward and your own test the only way to not have problems of course subsequent problems will continue to update second, decide whether to open the HTML5 page inside the appTo determine whether the current page is open within the app, a simple web front end does not address the need for clients to add their own app-related fields to useragent (useragent settings android:http://www.jincon.com/archives/ 354/) (UserAgent settings Ios:http://www.jianshu.com/p/5f02451b8e87)
var // Get useragent     Isinapp = Useragent.indexof ("Sunyuki") >=0; // query If there are related fields for the app

HTML5 page JS to determine whether to install the app, and to determine whether to open the HTML5 page inside the app

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.