user-agent 集合 浏览器类型集合 判断user-agent 是不是手机

分为常用的PC和手机(IPHONE,ANDROID,IPAD等)

PC

IE6:

Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)

IE7:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.3

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

IE8:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1)

IE9:

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)

Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)

 

CHROME:

Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24

 

MAC_OS_CHROME

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.65 Safari/535.11

SAFARI:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22

 

Firefox:

Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2

MAC_OS_FIREFOX

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20100101 Firefox/10.0.2

UBUNTU_FIREFOX

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0

OPERA

Opera/9.80 (Windows NT 5.1; U; ko) Presto/2.10.229 Version/11.61

 

###################

MOBILE

IPHONE4:

Mozilla/5.0 (iPhone; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405

IPAD:

Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; ko-kr) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Sa

IPOD:

Mozilla/5.0 (iPod; CPU iPhone OS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/

ANDROID:

Mozilla/5.0 (Linux; U; Android 2.3.3; ko-kr; SHW-M250K Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 M

BlackBerry

Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; ko) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.353 Mobile Safari/534.

HTC_Nexus_One

Mozilla/5.0 (Linux; U; Android 2.3.3; ko-kr; HTC_Nexus_One Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mob

GT-I9100

Mozilla/5.0 (Linux; U; Android 2.3.6; ko-kr; GT-I9100 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mo

 

基本上就这些了。

在处理浏览器兼容问题的时候可以根据UA判断操作系统,还有浏览器版本、类型来做相应的处理。

user-agent 全集

user-agent 集合

useragent 全集

useragent 集合

########

判断 user-agent 是不是 手机类型,包括iphone、ipad、nokia、等

private static final String[] MOBILE_KEYWORDS = {“iPhone”, “iPod”, “iPad”, “BlackBerry”, “Android”, “Windows CE”, “LG”, “MOT”, “SAMSUNG”, “ANDROID”, “HTC”, “SonyEricsson”};

public boolean getMobile() {

String userAgent =request.getHeader(“User-Agent”);

if (userAgent == null || userAgent.trim().length() == 0) {

return false;

}

for (String ua : MOBILE_KEYWORDS) {

if (userAgent.toLowerCase().indexOf(ua.toLowerCase()) >= 0) {

return true;

}

}

return false;

}

 

###

chrome 里切换user-agent 插件 user agent selector

预设值+我自己为了测试加的测试值

Android 2.3.5###Mozilla/5.0 (Linux; U; Android 2.3.5; ko-kr; HTC Desire HD A9191 Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4

Firefox 8 (Mac OS X 10.6)###Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0.1) Gecko/20100101 Firefox/8.0.1

Google Nexus One (Android 2.2)###Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

IPHONE 3 OS 3_1_3###Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; ko-kr) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7

Internet Explorer 6###Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Internet Explorer 7###Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)

Internet Explorer 8###Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)

Internet Explorer 9###Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)

Nokia 7110###Nokia 7110/1.0

Safari 5 (Mac OS X 10.6)###Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.52.7 (KHTML, like Gecko) Version/5.1.2 Safari/534.52.7

iPad 2 (iOS5)###Mozilla/5.0 (iPad; CPU 0S 5_0_1 like Mac OS X) AppleWebkit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A405 Safari/7534.48.3

iPad; U; CPU OS 4_2###Mozilla/5.0 (iPad; U; CPU OS 4_2_1 like Mac OS X; ko-kr) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2

iPhone 4 (iOS5)###Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3

iPhone OS 4_3###Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3 like Mac OS X; ko-kr) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2

 

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>