1. 程式人生 > >二維碼手機微信掃描識別裝置

二維碼手機微信掃描識別裝置

 // 獲取終端的相關資訊
        var Terminal = {
            // 辨別移動終端型別
            platform : function(){
                var u = navigator.userAgent, app = navigator.appVersion,ua = navigator.userAgent.toLowerCase();
                return {
                    isWeixin: ua.indexOf('micromessenger')!=-1,
                    // android終端或者uc瀏覽器
                    android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
                    // 是否為iPhone或者QQHD瀏覽器
                    iPhone: u.indexOf('iPhone') > -1
                };
            }()
        };
        // 根據不同的終端,跳轉到不同的地址
        var theUrl;
        var Gg = document.getElementById("Gg");
        var Ico = document.getElementById("ico");
        if (Terminal.platform.isWeixin) {
              Gg.style.display="block";
        }else {
            Gg.style.display="none";
            if(Terminal.platform.android){
                Ico.className = "iconfont icon-changyonglogo37";
            theUrl = '安卓apk地址';
            }
            else{
                Ico.className = "iconfont icon-IOS";
                 theUrl = 'ios安裝商店';
            };
         location.href = theUrl;
     }
    function install_loading(){
        location.href = theUrl;
    }