JS微信QQ判断跳转

<script>
//获取网址参数
function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}
//判断qq内部浏览器
var ua = navigator.userAgent.toLowerCase();
/*if (ua.match(/MicroMessenger/i) == "micromessenger") {//微信
        return "weixin";
}else */if (ua.match(/QQ/i) == "qq") {//QQ
	if(getQueryVariable("_wv") == ""){
		window.location.href=window.location.href+"?_wv=2";
	}else{
		
	}
}else if(ua.indexOf('mobile mqqbrowser')>-1){  
	if(getQueryVariable("_wv") == ""){
		window.location.href=window.location.href+"?_wv=2";
	}else{
		
	}
}
</script>