Use the agent to determine the browser version for life-saving sharing

Source: Internet
Author: User

Copy codeThe Code is as follows:
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 ",
"Cool dog ",
"Cheetah ",
"Window of the world ",
"QQ ",
"Maxthon ",
"Baidu audio and video ",
"Opera ",
"Chrome ",
"Safari ",
"360 ",
"UCWEB ",
"Googlebot ",
"Internet Explorer 11.0 "};
For (int I = 0; I <brorserEN. length; I ++ ){
If (userAgent. indexOf (brorserEN [I])>-1 ){
Return brorserCN [I];
}
}
If (userAgent. indexOf ("MSIE")>-1 ){
If (userAgent. indexOf ("MSIE 9.0")>-1 ){
Return "Internet Explorer 9.0 ";
} Else if (userAgent. indexOf ("MSIE 10.0")>-1 ){
Return "Internet Explorer 10.0 ";
} Else if (userAgent. indexOf ("MSIE 8.0")>-1 ){
Return "Internet Explorer 8.0 ";
} Else if (userAgent. indexOf ("MSIE 7.0")>-1 ){
Return "Internet Explorer 7.0 ";
} Else if (userAgent. indexOf ("MSIE 6.0")>-1 ){
Return "Internet Explorer 6.0 ";
}
Return "IE ";
}
Return "unknow Browser ";
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.