zoukankan      html  css  js  c++  java
  • js唤醒手机APP

    if (navigator.userAgent.match(/android/i)) {
    // 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为
    // 否则打开a标签的href链接
    var isInstalled;
    //下面是安卓端APP接口调用的地址,自己根据情况去修改
    var ifrSrc = 'cartooncomicsshowtwo://platformapi/startApp? type=0&id=${com.id}&phone_num=${com.phone_num}';
    var ifr = document.createElement('iframe');
    ifr.src = ifrSrc;
    ifr.style.display = 'none';
    ifr.onload = function() {
    // alert('Is installed.');
    isInstalled = true;
    alert(isInstalled);
    document.getElementById('openApp0').click();};
    ifr.onerror = function() {
    // alert('May be not installed.');
    isInstalled = false;
    alert(isInstalled);
    }
    document.body.appendChild(ifr);
    setTimeout(function() {
    document.body.removeChild(ifr);
    },1000);
    }
    //ios判断
    if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)){
    if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
    //Animation://com.yz.animation
    var isInstalled;
    //var gz = '{"comName":"${com.short_name}","comID":"${com.id}","comPhoneNum":"${com.phone_num}","type":"0"}';
    //var jsongz =JSON.parse(gz);

    //下面是IOS调用的地址,自己根据情况去修改
    var ifrSrc = 'Animation://?comName=${com.short_name}&comID=${com.id}&comPhoneNum=${com.phone_num}&type=0';var ifr = document.createElement('iframe');
    ifr.src = ifrSrc;
    ifr.style.display = 'none';
    ifr.onload = function() {
    // alert('Is installed.');
    isInstalled = true;
    alert(isInstalled);
    document.getElementById('openApp1').click();};
    ifr.onerror = function() {
    // alert('May be not installed.');
    isInstalled = false;
    alert(isInstalled);
    }
    document.body.appendChild(ifr);
    setTimeout(function() {
    document.body.removeChild(ifr);
    },1000);
    }
    }

    下面这个IOS可用,安卓不可用

    <meta name='apple-itunes-app' content='app-id=477927812'>

    1. <!-- a标签的链接,设置为对应的下载链接;点击打开的动作,在click事件中注册 -->  
    2. <href="https://itunes.apple.com/cn/app/id477927812" id="openApp">贴吧客户端</a>  
    3. <script type="text/javascript">  
    4.     document.getElementById('openApp').onclick = function(e){  
    5.         // 通过iframe的方式试图打开APP,如果能正常打开,会直接切换到APP,并自动阻止a标签的默认行为  
    6.         // 否则打开a标签的href链接  
    7.         var ifr = document.createElement('iframe');  
    8.         ifr.src = 'com.baidu.tieba://';  
    9.         ifr.style.display = 'none';  
    10.         document.body.appendChild(ifr);  
    11.         window.setTimeout(function(){  
    12.             document.body.removeChild(ifr);  
    13.         },3000)  
    14.     };  
    15. </script>  
  • 相关阅读:
    cocos2dx图片加密解密(npk方式)
    C#吾日三省吾身
    重写窗体的Enter事件(可对窗口的Enter事件做自己想做的事情)
    c#中显示Excel控件使用说明
    c# datagridview合并单元格
    AxSpreadsheet属性与方法说明
    c#实现货币转中文大写类
    jquery常用的插件1000收集
    [原创]站长自助平台一个帮助站长全自动实现一键采集、发贴(伪原创)、会员注册、交换连接的平台
    c#操作XML常用方法
  • 原文地址:https://www.cnblogs.com/zhangdiIT/p/6769139.html
Copyright © 2011-2022 走看看