zoukankan      html  css  js  c++  java
  • js检测手机上是否有此APP,有的话打开应用,没有的话跳转到appstore

     1     //html代码中 的 a 标签,以微信为例,默认的是调用weixin scheme,去打开本机的微信,如果没有则跳转到相应连接
     2     <a href="weixin://" class="btn-download">立即打开</a>
     3   
     4     // 为btn-download 绑定事件,如果在500ms内,没有解析到协议,那么就会跳转到下载链接 
     5      var appstore, ua = navigator.userAgent;
     6         if(ua.match(/Android/i)){ 
     7             appstore = 'market://search?q=com.singtel.travelbuddy.android';
     8         }
     9         if(ua.match(/iphone|ipod|ipad/)){
    10             appstore = "https://itunes.apple.com/cn/app/wei-xin/id414478124?mt=8&ign-mpt=uo%3D4"; 
    11         }
    12         function applink(fail){  
    13             return function(){  
    14                 var clickedAt = +new Date;  
    15                 // During tests on 3g/3gs this timeout fires immediately if less than 500ms.  
    16                 setTimeout(function(){  
    17                      // To avoid failing on return to MobileSafari, ensure freshness!  
    18                       if (+new Date - clickedAt < 2000){  
    19                           window.location = fail;  
    20                       }  
    21                 }, 500);      
    22             };  
    23         }  
    24         $('.icon-download, .btn-download')[0].onclick = applink(appstore); 

    或者 IOS设备上可以

    1 <meta name="apple-itunes-app" content="app-id=414478124" />
  • 相关阅读:
    MM-RGV、AGV 、IGV是什么
    WDA-FPM-4-用OVP做查询跳转到明细
    WDA-FPM-3-SEARCH(OIF)
    WDA-FPM-2-APPLICATION-TABSTRIP(OIF)
    WDA-FPM-1-Roadmap(GAF)
    WDA-BOPF业务对象处理框架
    WDA-WebDynpro Demo & FPM Demo
    WDA-参考路径
    MM-库存表
    洗礼灵魂,修炼python(12)--python关键词,包
  • 原文地址:https://www.cnblogs.com/ming-os9/p/8932490.html
Copyright © 2011-2022 走看看