• Android/IOS 微信及浏览器(h5)中唤起本地APP,唤起浮层,然后用外部浏览器打开唤起某本地APP


    1 前言

    微信点击链接,点击唤起某APP,在微信点开,默认是微信浏览器,点击button唤起,则会先提示浮层,然后用外部浏览器打开即可。

    作为记录使用。

    2 代码

    相关源码如下:

    html:

    <div class="container">
       <div class="main" >
         <div class="enterBtn" onclick="triggerStart()">
         </div>
        </div>
       <div class="openTip"  id="openTip">  </div>
    </div>
    

    Javascipt:  

        
    function IsIosAndroid(){
    if((/android/gi).test(navigator.appVersion)){
            return 1;
        }else if((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) || (navigator.userAgent.indexOf('iPad') != -1)){
            return 2;
        }
    }
    
    function openAndroid()
    {
          //appAndroid://a.b.com是某APP唤起的方式	
          window.location.href ="appAndroid://a.b.com";
    	
    }
    
    function openIos()
    {     
            //appios 是某APP唤起的方式
    	window.location.href = "appios://";
    }
    
    function is_weixn(){
        var ua = navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i)=="micromessenger") {
            return true;
        } else {
            return false;
        }
    }
    
    
    function triggerStart(){
    
        if(IsIosAndroid()==1){
            if(is_weixn())
            {
                document.getElementById("openTip").style.backgroundImage="url(../images/fuceng.png)";
                document.getElementById("openTip").style.display='block';
                return;
            }
            openAndroid();
        }else if(IsIosAndroid()==2){
            if(is_weixn())
            {
                document.getElementById("openTip").style.backgroundImage="url(../images/fuceng.png)";
                document.getElementById("openTip").style.display='block';
                return;
            }
            openIos();
        }
    }
    
    

    3 小结

    IOS9之前的 唤起方式不太一样,本文的ios系统为IOS10+  

  • 相关阅读:
    line-block,white-space,overflow
    JS操作cookie
    C#的位运算
    小常识:变量的修饰符和DEMO
    JS等号的小注释
    关于谷歌浏览器的小常识
    P2568 GCD
    P2522 [HAOI2011]Problem b
    P3455 [POI2007]ZAP-Queries
    P1447 [NOI2010]能量采集
  • 原文地址:https://www.cnblogs.com/fanbi/p/9221596.html
Copyright © 2020-2023  润新知