js判断是否安装app,安装打开app
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- <script>
- document.addEventListener('DOMContentLoaded', function () {
- document.querySelector('.downlink').addEventListener('click', function () {
- var loadDateTime = new Date(),
- href = location.href,
- appInnerUrlPrefix = 'http://a.app.qq.com/o/simple.jsp?pkgname=',
- newHref = href.substring(href.indexOf('//') + 2)
- var isiOS = navigator.userAgent.match('iPad') || navigator.userAgent.match('iPhone') || navigator.userAgent.match(
- 'iPod'),
- isAndroid = navigator.userAgent
- .match('Android'),
- isDesktop = !isiOS && !isAndroid;
- if (isiOS) {
- newHref = appInnerUrlPrefix + "com.zhulogic.xita_home";
- } else if (isAndroid) {
- newHref = appInnerUrlPrefix + "com.zhulogic.xita_home&g_f=991653";
- } else {
- newHref = appInnerUrlPrefix + "com.zhulogic.xita_home&g_f=991653";
- }
- setTimeout(function () {
- console.log(newHref);
- var timeOutDateTime = new Date();
- if (!loadDateTime || timeOutDateTime - loadDateTime < 1210) {
- location.href = newHref;
- }
- }, 1200);
- location.href = 'zhulogic://';
- }, false)
- }, false)
- </script>
- </head>
- <body>
- <div class="downlink" style="background-color: red;height: 300px;width: 300px;">
- </div>
- </body>
- </html>
-
IOS8.3(都可以跳转到下载页)
- safari可呼起APP
- 手机百度可呼起APP
- QQ不能呼起APP
- QQ空间可呼起APP
- 微信不能呼起APP
-
IOS9.2.1(都可以跳转到下载页)
- safari可呼起APP,但在呼起之前会弹出提示,需要选择“open”之后才会呼起
- 手机百度可呼起APP
- QQ空间可呼起APP
- QQ不能呼起APP
- 微信不能呼起APP
- 微博不能呼起APP
- 知乎不能呼起APP
-
魅族Android5.0.1(都可以跳转到下载页)
- 原生浏览器不能呼起APP
- QQ浏览器可呼起APP(但是会稍微延迟一会儿,时间可以接受)
- Chrome可呼起APP
- UC浏览器可呼起APP,但是在呼起之前会弹出提示,需要选择“仅本次允许”之后才会呼起
- QQ可呼起APP
- 微信可呼起APP(APP的呼起会晚于跳转到下载页)
- 手机百度可呼起APP
- 微博不能呼起APP
-
三星Android4.4(都可以跳转到下载页)
- 原生浏览器可呼起APP
- QQ可呼起APP(打开了2次)
- 微信不能呼起
- 手机百度可呼起APP
- QQ浏览器可呼起APP