代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
Java
】
通过UserAgent判读客户端的浏览器信息
作者:
/ 发布于
2017/7/21
/
446
//Windows NT 6.2 Win8 //Windows NT 6.1 Win7 //Windows XP //Windows RT Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; ARM; Trident/6.0) //(Windows NT 6.1; Trident/7.0; BOIE9;ZHCN; rv:11.0) like Gecko ---IE 11 //"Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)" //"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.27.1 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7" //"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.66 Safari/537.36" //"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0" //"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36" //"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8) AppleWebKit/536.25 (KHTML, like Gecko) Version/6.0 Safari/536.25" function parser(userAgent) { var start = userAgent.indexOf("("); userAgent = userAgent.substring(start,userAgent.length); var os = "Windows"; var bit = "32位"; var brower = ""; if(userAgent.indexOf("Windows NT 6.2")!=-1){ os = "Win8"; if(userAgent.indexOf("ARM;")!=-1){ os = "WinRT"; } }else if(userAgent.indexOf("Windows NT 6.1")!=-1){ os = "Win7"; }else if(userAgent.indexOf("Windows XP")!=-1){ os = "WinXP"; }else if(userAgent.indexOf("Linux")!=-1){ os = "Linux"; }else if(userAgent.indexOf("Mac")!=-1){ os = "Mac"; } if(userAgent.indexOf("WOW64")!=-1||userAgent.indexOf("_64")!=-1||userAgent.indexOf("X64")!=-1||userAgent.indexOf("x64")!=-1){ bit = "64位"; } if(userAgent.indexOf("MSIE")!=-1){ brower = "IE"; var start = userAgent.indexOf("MSIE"); var end = userAgent.indexOf(";",start); brower = brower+ userAgent.substring(start+5,end); }else if(userAgent.indexOf("rv:")!=-1){ brower = "IE"; var start = userAgent.indexOf("rv:"); var end = userAgent.indexOf(")",start); brower = brower+ userAgent.substring(start+3,end); }else if(userAgent.indexOf("Firefox")!=-1){ brower = "Firefox"; var start = userAgent.indexOf("Firefox/"); brower = brower + userAgent.substring(start+"Firefox".length+1,userAgent.length); }else if(userAgent.indexOf("Chrome")!=-1){ brower = "Chrome"; var start = userAgent.indexOf("Chrome/"); var end = userAgent.indexOf(".",start); end = userAgent.indexOf(".",end+1); brower = brower + userAgent.substring(start+"Chrome".length+1,end); }else if(userAgent.indexOf("Safari")!=-1){ //Version/5.1.2 brower = "Safari"; var start = userAgent.indexOf("Version/"); var end = userAgent.indexOf(" ",start); brower = brower + userAgent.substring(start+"Version".length+1,end); } return os+"_"+bit+"_"+brower+userAgent; }
试试其它关键字
同语言下
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
可能有用的
.
List 切割成几份 工具类
.
一行一行读取txt的内容
.
Java PDF转换成图片并输出给前台展示
.
java 多线程框架
.
double类型如果小数点后为零则显示整数否则保留两位小
.
将图片转换为Base64字符串公共类抽取
.
sqlParser 处理SQL(增删改查) 替换schema 用于多租户
.
JAVA 月份中的第几周处理 1-7属于第一周 依次类推 29-
.
java计算两个经纬度之间的距离
.
输入时间参数计算年龄
贡献的其它代码
Label
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3