复制代码 代码如下:
public static String getBrowser(String userAgent) {
if(userAgent==null||userAgent.trim().length()1){
return "unknow ";
}
String[]brorserEN=new String[]{
"MyIE2",
"Firefox",
"KuGooSoft",
"LBBROWSER",
"TheWord",
"QQ",
"Maxthon",
"BIDUPlayerBrowser",
"Opera",
"Chrome",
"Safari",
"9A334",
"UCWEB",
"googlebot",
"rv 11.0"};
String[]brorserCN=new String[]{
"MyIE2",
"Firefox",
"酷狗",
"猎豹",
"世界之窗",
"QQ",
"Maxthon",
"百度影音",
"Opera",
"Chrome",
"Safari",
"360",
"UCWEB",
"googlebot",
"IE 11.0"};
for(int i=0;ibrorserEN.length;i++){
if (userAgent.indexOf(brorserEN[i]) > -1) {
return brorserCN[i];
}
}
if (userAgent.indexOf("MSIE") > -1) {
if(userAgent.indexOf("MSIE 9.0")>-1){
return "IE 9.0";
}else if(userAgent.indexOf("MSIE 10.0")>-1){
return "IE 10.0";
}else if(userAgent.indexOf("MSIE 8.0")>-1){
return "IE 8.0";
}else if(userAgent.indexOf("MSIE 7.0")>-1){
return "IE 7.0";
}else if(userAgent.indexOf("MSIE 6.0")>-1){
return "IE 6.0";
}
return "IE";
}
return "unknow Browser";
}
您可能感兴趣的文章:- php中修改浏览器的User-Agent来伪装你的浏览器和操作系统
- 解析file_get_contents模仿浏览器头(user_agent)获取数据
- javascript通过navigator.userAgent识别各种浏览器
- JS通过分析userAgent属性来判断浏览器的类型及版本
- js识别不同浏览器基于userAgent做判断
- 如何判断微信内置浏览器(通过User Agent实现)
- jquery插件推荐浏览器嗅探userAgent
- asp获得浏览器agent信息代码