1.js:function sourceDevice(){
var ua = navigator.userAgent.toLowerCase();
if(ua.indexOf("iphone") != -1){
return IPHONE;
}else if(ua.indexOf("android") != -1){
return ANDROID;
}else if(ua.indexOf("ipad") != -1){
return IPAD;
}else if(ua.indexOf("windows nt") != -1){
return PC;
}else{
return OTHERDEVICE;
}
}
function sourceBrow(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return WEIXIN;
}else if (ua.indexOf("ucbrowser") != -1){
return UC;
}else if(ua.indexOf("360 aphone browser") != -1){
return THREESIXZERO;
}else if(ua.indexOf("safari") != -1){
if(sourceType == 1){
return SAFARI;
}
return OTHERBROW;
}else{
return OTHERBROW;
}
}
2.java
String header=request.getHeader("user-agent");
转载于:https://blog.51cto.com/9686567/1605931