一.微信判断:
1.php
/**
* 微信判断
* @return bool TRUE:is weixin FASLE:not weixin
*/
private function is_weixin()
{
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== FALSE) {
return TRUE;
}
return FALSE;
}
2.js
function is_weixin(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return true;
} else {
return false;
}
}
二.移动设备判断
js
function device_type(){
var u = navigator.userAgent;
//var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
if(!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)){
return true;
}else{
return false;
}
}