微信中用h5下载app

时间:2021-06-18 19:07:44   收藏:0   阅读:0

技术图片

技术图片

<script type="text/javascript">
    function download() {
        // 判断是否是微信内
        var u = navigator.userAgent;
        var isWeixin = !!/MicroMessenger/i.test(u);
        if (isWeixin) {
            // 控制蒙层
            document.getElementById(‘mask‘).style.display = ‘block‘;
        } else {
            var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //android终端
            var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            //android端
            if (isAndroid) {
                let hidden =
                    window.document.hidden ||
                    window.document.mozHidden ||
                    window.document.msHidden ||
                    window.document.webkitHidden;
                if (typeof hidden == "undefined" || hidden == false) {
                    window.location.href = "https://xxx.apk"; //安卓应用市场地址
                }
            } else if (isIOS) {
                //ios端
                let hidden =
                    window.document.hidden ||
                    window.document.mozHidden ||
                    window.document.msHidden ||
                    window.document.webkitHidden;
                if (typeof hidden == "undefined" || hidden == false) {
                    window.location.href = "http://apps.apple.com/cn/app/id387682726"; //app store地址
                }
            }
        }
    }
</script>  
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!