zoukankan      html  css  js  c++  java
  • 如何用js检测手机是否安装某个app

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

        <a href="weixin://" class="btn-download">立即打开</a>
      
        // 为btn-download 绑定事件,如果在500ms内,没有解析到协议,那么就会跳转到下载链接
         var appstore, 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){ 
                return function(){ 
                    var clickedAt = +new Date; 
                    // 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 (+new Date - clickedAt < 2000){ 
                              window.location = fail; 
                          
                    }, 500);     
                }; 
            
            $('.icon-download, .btn-download')[0].onclick = applink(appstore);
  • 相关阅读:
    五、页脚footer
    一、页眉header
    四、(2)列布局+媒体查询
    二、导航栏nav
    coredns介绍
    pandas指定列索引和行索引
    学习笔记246—国家自然科学基金申请书写作攻略【收藏】
    Axios请求传参的格式
    NodeJspm2常用命令
    FastAPI实现谷歌DialogFlow 接口问答批量导入导出和批量删除 DialogFlow batch import and export Q&A interface
  • 原文地址:https://www.cnblogs.com/zhoubingyan/p/8324235.html
Copyright © 2011-2022 走看看