美文网首页
扫码下载app

扫码下载app

作者: Sasoli | 来源:发表于2018-03-23 13:50 被阅读0次
<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>手机APP下载页</title>
    <script type="text/javascript">
        var theUrl;
        // 获取终端的相关信息
        var Terminal = {
            // 辨别移动终端类型
            platform : function(){
                var u = navigator.userAgent, app = navigator.appVersion;
                return {
                    // android终端或者uc浏览器
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
                    // 是否为iPhone或者QQHD浏览器
                    iPhone: u.indexOf('iPhone') > -1 ,
                    // 是否iPad
                    iPad: u.indexOf('iPad') > -1 ,
                    // 是否是通过微信的扫一扫打开的
                    weChat: u.indexOf('MicroMessenger') > -1
                };
            }(),
            // 辨别移动终端的语言:zh-cn、en-us、ko-kr、ja-jp...
            language : (navigator.browserLanguage || navigator.language).toLowerCase()
        }

        // 根据不同的终端,跳转到不同的地址
        
        if(Terminal.platform.android){
            theUrl = '你的Android APP对应下载地址:apk文件地址';
        }else if(Terminal.platform.iPhone){
            theUrl = '你的iPhone APP对应下载地址:APP Store地址';
        }else if(Terminal.platform.iPad){
            // 还可以通过language,区分开多国语言版
            switch(Terminal.language){
                case 'en-us':
                    theUrl = '你的iPad APP(英文版)对应下载地址:APP Store地址';
                    break;
                case 'ko-kr':
                    theUrl = '你的iPad APP(韩语版)对应下载地址:APP Store地址';
                    break;
                case 'ja-jp':
                    theUrl = '你的iPad APP(日文版)对应下载地址:APP Store地址';
                    break;
                default:
                    theUrl = '你的iPad APP(中文版-默认)对应下载地址:APP Store地址';
            }
        }
    
        location.href = theUrl;
        //  分割线-----------------------------------------------------------分割线
        // 如果要分渠道,也是可以的,渠道区分:from=xx
        var From = (function(){
            var searchInfo = location.search.substr(1).split('&'),
                item,
                from;
            for(var i= 0,len=searchInfo.length;len > 1 && i<len;i++){
                item = searchInfo[i].split('=');
                if(item[0] === 'from') {
                    from = item[1];
                    break;
                }
            }
            return from;
        })();
   
        // 根据不同的终端,跳转到不同的地址
        var theUrl;
         
        // 以安卓为例
        // 另外:微信扫一扫后打开连接,是不能直接进行下载的,所以你可以将apk放到微云上,使用微云上的apk地址
        if(Terminal.platform.android){
            // 这里区分渠道
            switch(From){
                case 'baidu':
                    if(Terminal.platform.weChat) {
                        theUrl = '你的App:微云上的地址';
                    }else{
                        theUrl = '你的APP:baidu定制版';
                    }
                    break;
                case 'google':
                    if(Terminal.platform.weChat) {
                        theUrl = '你的App:微云上的地址';
                    }else{
                        theUrl = '你的APP:google定制版';
                    }
                    break;
                default:
                    if(Terminal.platform.weChat) {
                        theUrl = '你的App:微云上的地址';
                    }else{
                        theUrl = '你的APP:官方版';
                    }
            }
        }
   
        location.href = theUrl;
    </script>
</head>
<body>
</body>
</html>

相关文章

网友评论

      本文标题:扫码下载app

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