腾讯webQQ判断浏览器

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<body>
<script>
var g = {
	isHTML : '${wpatype}',
	tuin : '80191460',
	closeWindow: function(){
		if(g.isHTML == 'JS'){
			return;
		}
		var browserName = navigator.appName;
		if(browserName == "Netscape"){
			window.open('', '_self', '');
			window.close();
		} else if(browserName == "Microsoft Internet Explorer"){
			window.opener = null;
			window.open('', '_top');
			window.top.close();
		}
	},
	reportM: function(id){
		var img = document.createElement("img");
		img.src = "http://wp.qq.com/cgi-bin/api_attr?id=" + id + "&SigT=" + g.sigt;
	},
	reportB: function(id){
		var img = new Image(), timestamp = +(new Date());
		img.src = 'http://cgi.connect.qq.com/report/report?strValue=' + g.tuin + '&nValue=' + id + '&tag=0&t=' + timestamp;
	},
	reportBNL: function(arrId){
		var img = new Image(), timestamp = +new Date();
		for(var i = 0, len = arrId.length; i < len; i++){
			arrId[i] = g.tuin + "_" + arrId[i] + "_0";
		}
		img.src = 'http://cgi.connect.qq.com/report/report?log=' + arrId.join("|") + '&tag=0&t=' + timestamp;
	},
	checkActiveX: function(){
		var kXmlHttp = null;
		try {
			if(typeof XMLHttpRequest != "undefined"){
				kXmlHttp = new XMLHttpRequest();
				return true;                
			}
		} catch(e) {}
		var aVersionhs = ["MSXML2.XMLHttp.3.0","MSXML2.XMLHttp.6.0","MSXML2.XMLHttp","Microsoft.XMLHttp","MSXML2.XMLHttp.5.0","MSXML2.XMLHttp.4.0"];
		for(var i = 0; i < aVersionhs.length; i++){
			try {
				kXmlHttp = new ActiveXObject(aVersionhs[i]);
				return true;
			} catch(e) {}
		}
		return false;
	},
	checkBrowser : function(rp){
		var ua = navigator.userAgent.toLowerCase(),
			browser, version,
			match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
			/(webkit)[ \/]([\w.]+)/.exec(ua) ||
			/(opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) ||
			/(msie) ([\w.]+)/.exec(ua) ||
			ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(ua) || [];

		browser = match[1] || "";
		version = match[2] || "0";
		this.ie = browser == "msie";
		this.chrome = browser == "chrome";
		this.webkit = browser == "webkit";
		this.firefox = browser == "mozilla";
		this.opera = browser == "opera";
		this.browserVersion = parseInt(version, 10);
		if(this.chrome || this.webkit){
			rp.push(10759);
		}
		if(this.chrome){
			rp.push(this.browserVersion<23?10761:10762);
		}
		if(this.firefox){rp.push(10760);}
		if(browser == 'opera' || browser == ''){
			rp.push(10763);
		}
	},
	checkPlatform : function(rp){
		var pf = navigator.platform.toLowerCase();
		switch(true){
			case (/win/).test(pf) : rp.push(10753);
				break;
			case (/android/).test(pf) : rp.push(10754);
				break;
			case (/iphone/).test(pf) :
			case (/ipod/).test(pf) :
			case (/ipad/).test(pf) : rp.push(10755);
				break;
			case (/mac/).test(pf) : rp.push(10756);
				break;
			case (/linux/).test(pf) : rp.push(10757);
				break;
			default : rp.push(10758);
				break;
		}
	},
	tryPlugin : function(plugin){
		var plugin = "application/" + plugin;
		if(navigator.mimeTypes[plugin]){
			var obj = document.createElement("embed");		
				obj.type = plugin;
				obj.style.width = "0px";
				obj.style.height = "0px";
			document.body.appendChild(obj);
			try{
				ok = obj.InitActiveX("TimwpDll.TimwpCheck");
			}catch(e){
				g.webChat();
				return false;
			}
			
			if(ok){
				var qqver = obj.GetHummerQQVersion();
				if(!qqver){
					g.webChat();
					return false;
				}
				return true;
			} else {
				g.webChat();
				return false;
			}
		} else {
			g.webChat();
			return false;
		}
	},
	webChat : function(){
		setTimeout(function(){
			window.location = "http://wp.qq.com/open_webaio.html?sigt=" + g.sigt + "&sigu=" + g.sigu + "&tuin=" + g.tuin;
		}, 200);
	}
};

var init = function(){
	var tencentSeries = "tencent://message/?Menu=yes&uin=1111111&Site=&Service=201&sigT=a24cb97f2185099ebd97e3e77b1b0e653135d85fe63dc27908cc13ded97cfd17048f9ceb6d5a66f7e31e948b0d7f073e&sigU=29a5998c41261dd2adabd3421621b585f433b5c4336840fd6715f773844a1bef1905b0d19fe82db1", reportPool = [];
	// reportPool.push(10582);
	g.reportB(10582);
	if(tencentSeries) {
		reportPool.push(10584);
	}
	g.sigt = tencentSeries.replace(/^\S+sigT=/g, "").replace(/&\S+$/g, "");
	g.sigu = tencentSeries.replace(/^\S+sigU=/g, "").replace(/&\S+$/g, "");
	var from = window.location.search.replace(/^\S+from=/g, "").replace(/&\S+$/g, "");
	if(from == 'discuz'){
		reportPool.push(10774);
	}

	g.checkBrowser(reportPool);
	g.checkPlatform(reportPool);

	if(g.ie){
		if(window.ActiveXObject){
			try{
				var PTLoginCtrl = new ActiveXObject("SSOAxCtrlForPTLogin.SSOForPTLogin2");
				var vInitData = PTLoginCtrl.CreateTXSSOData();
				PTLoginCtrl.InitSSOFPTCtrl(0, vInitData);
				var vOptData = PTLoginCtrl.CreateTXSSOData();
				var vResult = PTLoginCtrl.DoOperation(2, vOptData);
				var vAccountList = vResult.GetArray("PTALIST");
				if(vResult != null){
					reportPool.push(10708);
					var uListSize = vAccountList.GetSize();
					if(uListSize > 0){
						reportPool.push(10709);
					} else {
						reportPool.push(10710);
					}
				}
			} catch(e) {}
		}
	} else {
		if(navigator.mimeTypes["application/nptxsso"]){
			var obj = document.createElement("embed"), ok;		
			obj.type="application/nptxsso";
			obj.style.width="0px";
			obj.style.height="0px";
			document.body.appendChild(obj);
			try{
				ok = obj.InitPVANoST();
			}catch(e){}
			
			if(ok){
				reportPool.push(10708);
				var count = obj.GetPVACount();
				if(count>0){
					reportPool.push(10709);
				} else {
					reportPool.push(10710);
				}
			}
		}
	}

	if(!g.ie){
		g.reportM(2);
		reportPool.push(10583);
		g.reportBNL(reportPool);
		if(g.firefox || (g.chrome && g.browserVersion < 23) || g.webkit){
			if(!g.tryPlugin("qscall-plugin")){
				// return;
			}
		} else if(g.chrome){
			if(!g.tryPlugin("npchrome-plugin")){
				// return;
			}
		} else if(g.opera){
			g.webChat();
			return;
		}

		var iframe = document.createElement("iframe");
		iframe.setAttribute('frameborder', '0', 0);
		iframe.src = tencentSeries;
		document.body.appendChild(iframe);
		window.setTimeout(function(){
			g.closeWindow();
		}, 2000);
	} else { //ie
		reportPool.push(10667);
		if (!g.checkActiveX()){
			reportPool.push(10652);
			g.reportBNL(reportPool);
            g.webChat();
			return;
		}
		reportPool.push(10668);
		try	{
			var cpTimwp = new ActiveXObject("TimwpDll.TimwpCheck");
			if(cpTimwp){
				reportPool.push(10669);
				g.reportBNL(reportPool);
				window.location=tencentSeries;
				window.setTimeout(g.closeWindow,200);
				return;
			}
		} catch(e) {
			g.reportM(1);
			reportPool.push(10632);
			g.reportBNL(reportPool);
            g.webChat();
		}
	}
};
//init();
</script>
</body>
</html>

 

你可能感兴趣的:(Web)