How to use JS to detect whether the phone installs an app

Source: Internet
Author: User

//html代码中 的 a 标签,以为例,默认的是调用weixin scheme,去打开本机的,如果没有则跳转到相应连接

    <a href="weixin://"class="btn-download">立即打开</a>      // 为btn-download 绑定事件,如果在500ms内,没有解析到协议,那么就会跳转到下载链接     varappstore, ua = navigator.userAgent;        if(ua.match(/Android/i)){            appstore = ‘market://search?q=com.singtel.travelbuddy.android‘;        }        if(ua.match(/iphone|ipod|ipad/)){            appstore = "https://itunes.apple.com/cn/app/wei-xin/id414478124?mt=8&ign-mpt=uo%3D4";        }        function applink(fail){             returnfunction(){                 varclickedAt = +newDate;                 // During tests on 3g/3gs this timeout fires immediately if less than 500ms.                 setTimeout(function(){                      // To avoid failing on return to MobileSafari, ensure freshness!                       if(+newDate - clickedAt < 2000){                           window.location = fail;                       }                 }, 500);                 };         }         $(‘.icon-download, .btn-download‘)[0].onclick = applink(appstore);

How to use JS to detect whether the phone installs an 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.