When developing a public account, you need to know that the current browser is a built-in browser. How can this problem be determined? This is only through the browser's UserAgent to determine the development of public accounts, a large part of which is the development of micro-sites, we need to know that the current browser is a built-in browser, so how to judge?
Built-in browser User Agent
To determine the built-in browser, you first need to obtain the User Agent of the built-in browser. After detection by the browser on the iPhone, its User Agent is:
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 identify the keyword MicroMessenger to determine whether the browser is built in.
JavaScript-based judgment
Function is_weixin () {var ua = navigator. userAgent. toLowerCase (); if (ua. match (/MicroMessenger/I) = "micromessenger") {return true;} else {return false ;}}
PHP-based judgment
Function is_weixin () {if (strpos ($ _ SERVER ['HTTP _ USER_AGENT '], 'micromessenger ')! = False) {return true;} return false ;}