客户端和服务器端判断请求来至微信客户端
有两种情况:有两种情况: clientclient 端区分端区分 添加 js 代码 1. varvar browser={ 2. 3. versions:functionfunction(){ 4. 5. varvar u = navigator.userAgent, app = navigator.appVersion; 6. 7. returnreturn {//移动终端浏览器版本信息 8. 9. trident: u.indexOf( Trident ) -1, //IE 内核 10. 11. presto: u.indexOf( Presto ) -1, //opera 内核 12. 13. webKit: u.indexOf( AppleWebKit ) -1, //苹果、谷歌内核 14. 15. gecko: u.indexOf( Gecko ) -1 ]+;( U;)? CPU.+Mac OS X/), //ios 终端 20. 21. android: u.indexOf( Android ) -1 || u.indexOf( Linux ) -1, //android 终端 或者 uc 浏览器 22. 23. iPhone: u.indexOf( iPhone ) -1 || u.indexOf( Mac ) -1, //是否为iPhone或者 QQHD 浏览器 24. 25. iPad: u.indexOf( iPad ) -1, //是否 iPad 26. 27. webApp: u.indexOf( Safari ) == -1 //是否 web 应该程序,没有头部与底部 28. 29. }; 30. 31. }(), 32. 33. language:(navigator.browserLanguage || navigator.language).toLowerCase() 34. 35. } 36. 37. document.writeln(“语言版本: “+browser.language); 38. 39. document.writeln(“ 是否为移动终端: “+browser.versions.mobile); 40. 41. document.writeln(“ ios 终端: “+browser.versions.ios); 42. 43. document.writeln(“ android 终端: “+browser.versions.android); 44. 45. document.writeln(“ 是否为 iPhone: “+browser.versions.iPhone); 46. 47. document.writeln(“ 是否 iPad: “+browser.versions.iPad); 48. 49. document.writeln(navigator.userAgent); 50. 51. serverserver 端区分端区分 需要实现的逻辑示例: If ( QQ 浏览器) { //处理方案 A } else { //处理方案 B } key is Host, value is 10.10.42.132:9002 key is Connection, value is keep-alive key is Upgrade-Insecure-Requests, value is 1 key is User-Agent, value is Mozilla/5.0 (Linux; Android 6.0.1;vivoX9Build/MMB29M;wv)AppleWebKit/537.36 (KHTML,likeGecko)Version/4.0Chrome/53.0.2785.49 MobileMQQBrowser/6.2TBS/043220Safari/537.36 MicroMessenger/6.5.7.1041 NetType/WIFI Language/zh_CN keyisAccept,valueis text/html,application/xhtml+xml,application/xml;q=0.9 ,image/webp,image/wxpic,image/sharpp,*/*;q=0.8 key is Accept-Encoding, value is gzip, deflate key is Accept-Language, value is zh-CN,en-US;q=0.8 keyisCookie,valueis JSESSIONID=1ci2brinz9khl1w2efvdqgvoft 总结: 1. 在 Android 下,返回 Mozilla/5.0 (Linux; Android 6.0.1; vivo X9 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/53.0.2785.49MobileMQQBrowser/6.2TBS/043220 Safari/537.36MicroMessenger/6.5.7.1041NetType/WIFI Language/zh_CN 可以看到,微信浏览器为 MicroMessenger,后面还有其版本号 2. 在 iphone 下, 返回 Mozilla/5.0 (iPhone; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B411 MicroMessenger/6.5.3 NetType/WIFI Language/zh_CN 3. Android QQ 浏览器,返回 Mozilla/5.0 (Linux; U; Android 6.0.1; zh-cn; vivo X9 Build/MMB29M)AppleWebKit/537.36(KHTML,like Gecko)Version/4.0 Chrome/37.0.0.0 MQQBrowser/7.5 Mobile Safari/537.36 可以看到,QQ 浏览器为MQQBrowser 4. Iphone QQ 浏览器,返回 Mozilla/5.0 (iPhone 6; CPU iPhone OS 8_1 like Mac OS X) AppleWebKit/600.1.4(KHTML,likeGecko)Version/8.0 MQQBrowser/7.4.1Mobile/12B411Safari/8536.25 MttCustomUA/2 QBWebViewType/1 5. Weichat PC 端,window , 返回 Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 MicroMessenger/