How to judge the Micro message built-in browser

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
When the Micro message public account development, of which a large block is the development of micro site, we need to know the current browser is Micro message built-in browser, so how to judge it? 

Micro message browser built User Agent

How to judge the Micro message built-in browser, first of all need to get Micro message browser built User Agent, after testing in the iPhone Micro message browser, it is User Agent: 

Mozilla/5.0 (iPhone; CPU iPhone OS 6_1_3 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Mobile/10B329 MicroMessenger/5.0.1
So by the keyword recognition MicroMessenger to determine whether Micro message built-in browser. 

Judging by JavaScript

function is_weixin(){
	var ua = navigator.userAgent.toLowerCase();
	if(ua.match(/MicroMessenger/i)=="micromessenger") {
		return true;
 	} else {
		return false;
	}
}
Judging by PHP

function is_weixin(){ 
	if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
			return true;
	}	
	return false;
}

 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Molly at December 15, 2013 - 10:04 AM