复制代码代码如下所示:
字符串(字符串getbrowser UserAgent){
如果(UserAgent = = null | | useragent.trim()。长度()<1){
返回未知;
}
brorseren =新的字符串字符串{ } { } {
MYIE2
火狐
kuosoft
lbbrowser
世界
QQ
傲游
biduplayerbrowser
歌剧
铬
Safari
9a334
UCWEB
oglebot
RV 11};
brorsercn =新的字符串字符串{ } { } {
MYIE2
火狐
酷狗
猎豹
世界之窗
QQ
傲游
百度视频
歌剧
铬
Safari
360
UCWEB
oglebot
ie 11};
为(int i = 0;i < brorseren.length;i++){
如果(useragent.indexof(brorseren {我})> 1){
返回brorsercn {我};
}
}
如果(useragent.indexof(MSIE)> 1){
如果(useragent.indexof(MSIE 9 )> 1){
返回ie 9;
} else if(useragent.indexof(MSIE 10 )> 1){
返回ie 10;
} else if(useragent.indexof(MSIE 8 )> 1){
返回ie 8;
} else if(useragent.indexof(MSIE 7 )> 1){
返回ie 7;
} else if(useragent.indexof(MSIE 6 )> 1){
返回ie 6;
}
返回ie;
}
返回未知的浏览器;
}