JS 判断各客户端 判断是移动端

4 min read
<script type="text/javascript">
var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
var browser = navigator.userAgent.toLowerCase(); 
for (var i=0; i<mobileAgent.length; i++){
	if (browser.indexOf(mobileAgent[i])!=-1){ // 判断是移动端
                // 替换域名, 也可以做其他操作
		window.location.href = window.location.href.replace('www', 'm');
		break;
	}
}
</script>

qq浏览器 ['mqqbrowser']

微信或qq ['micromessenger','qq']

对于微信和qq的判断 要判断不是qq浏览器