美文网首页
H5 唤起APP 如果安装了app 打开,没有则下载

H5 唤起APP 如果安装了app 打开,没有则下载

作者: 秋叶红90 | 来源:发表于2020-11-06 01:51 被阅读0次
var url = {
                open:'testA://990000'
            }
            var timer = 0;
              function test (btnType){//0表示直接下载无需提示。1表示需要提示。
                    var ua = window.navigator.userAgent || '';
                    var isIos = /iphone|ipad|ipod/i.test(ua);
                    if (isIos) {
                        var tagA = document.createElement('a');
                        tagA.setAttribute('href', url.open);
                        tagA.style.display = 'none';
                        document.body.appendChild(tagA);
                        tagA.click();
                    } else {
                        var iframe = document.createElement('iframe');
                        var body = document.body;
                        iframe.style.cssText='position:absolute;width:1px;height:1px;';
                        iframe.src = url.open;
                        body.appendChild(iframe);
                    }
                    console.log(url.open)
                    timer = setTimeout(function() {
                        window.location.href = "https://下载地址/1168916328" + url.open;
                        // alert("未安装")
                        // console.log("https://bigo.onelink.me/1168916328" + url.open)
                        // window.location.href = "https://bigo.onelink.me/1168916328" + url.open;
                    }, 50);
                }
            
            test();

相关文章

网友评论

      本文标题:H5 唤起APP 如果安装了app 打开,没有则下载

      本文链接:https://www.haomeiwen.com/subject/kqrzvktx.html