因了需要用到這些信息,所以總結(jié)一下,方便以后參閱
通過request.getHeader("User-Agent")大致可以取得用戶瀏覽器的信息
如果里面包含:
"msie"-->MicroSoft?
"opera" -->Opera Software
"mozilla"-->Netscape Communications
如果取瀏覽器版本信息
String str = request.getHeader("User-Agent");
MS :? str.substring(str.indexOf("msie") + 5);
Other :
tmpString = (str.substring(tmpPos = (str.indexOf("/")) + 1, tmpPos + str.indexOf(" "))).trim(); ?//沒有親自試
操作系統(tǒng)部分,不啰嗦了
private void setOs()
{
if (this.userAgent.indexOf("win") > -1){
? if (this.userAgent.indexOf("windows 95") > -1 || this.userAgent.indexOf("win95") > -1){
???? this.os = "Windows 95";
? }
? if (this.userAgent.indexOf("windows 98") > -1 || this.userAgent.indexOf("win98") > -1){
???? this.os = "Windows 98";
? }
? if (this.userAgent.indexOf("windows nt") > -1 || this.userAgent.indexOf("winnt") > -1){
????? this.os = "Windows NT";
? }
? if (this.userAgent.indexOf("win16") > -1 || this.userAgent.indexOf("windows 3.") > -1){
????? this.os = "Windows 3.x";
? }
?}
}
獲取語言request.getHeader("Accept-Language");
詳細(xì)信息可以再分解....
只有注冊用戶登錄后才能發(fā)表評論。 | ||
![]() |
||
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
|
||
相關(guān)文章:
|
||