java 获取浏览器类型
程序员文章站
2022-07-01 18:56:34
...
public String getBrowserType(HttpServletRequest request)
{
String type = "ie";
String browserName = request.getHeader("USER-AGENT").toLowerCase();
if (browserName.indexOf("msie") > 0) {
type = "ie";
}
if (browserName.indexOf("firefox") > 0) {
type = "firefox";
}
if (browserName.indexOf("chrome") > 0) {
type = "chrome";
}
if (browserName.indexOf("opera") > 0) {
type = "opera";
}
if(browserName.indexOf("gecko")>0 && browserName.indexOf("rv:11")>0){
type="ie11";
}
return type;
}
{
String type = "ie";
String browserName = request.getHeader("USER-AGENT").toLowerCase();
if (browserName.indexOf("msie") > 0) {
type = "ie";
}
if (browserName.indexOf("firefox") > 0) {
type = "firefox";
}
if (browserName.indexOf("chrome") > 0) {
type = "chrome";
}
if (browserName.indexOf("opera") > 0) {
type = "opera";
}
if(browserName.indexOf("gecko")>0 && browserName.indexOf("rv:11")>0){
type="ie11";
}
return type;
}