復(fù)制代碼 代碼如下:
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來偽裝你的瀏覽器和操作系統(tǒng)
- 解析file_get_contents模仿瀏覽器頭(user_agent)獲取數(shù)據(jù)
- javascript通過navigator.userAgent識(shí)別各種瀏覽器
- JS通過分析userAgent屬性來判斷瀏覽器的類型及版本
- js識(shí)別不同瀏覽器基于userAgent做判斷
- 如何判斷微信內(nèi)置瀏覽器(通過User Agent實(shí)現(xiàn))
- jquery插件推薦瀏覽器嗅探userAgent
- asp獲得瀏覽器agent信息代碼