最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
怎样用asp来判断客户端浏览器和操作系统的类型。
时间:2008-01-12 编辑:简简单单 来源:一聚教程网
很多人都在问这个问题阿,下面就是答案了:)
-----------------------------------------
首先她要用到asp的ServerVarialbles这个集合。在ServerVarialbles有这样一项HTTP_USER_AGENT,他有什么作用呢?他的作用就是获取客户端浏览器的基本信息和操作系统的版本阿,如是什么牌子的浏览器阿(一般就是IE和netscape了),他们的版本号什么的,下面我用一个程序来说明她的用法,文件命名为CheckBrowse.asp。
$U2 Forum rautinee原创$
$http://u2bbs.126.com$
'++++++++++++++以下是程序的正文+++++++++++++++++
>
浏览器检测
<%
Dim BrowseMsg,BrowseVersion,SystemVersion
BrowseMsg=Request.ServerVariables("HTTP_USER_AGENT")
'+++++++++++一个基本判别操作系统的函数+++++++++++
Function SystemCheck()
if inStr(BrowseMsg,"Windows 98") then
SystemCheck="Windows 98"
else if inStr(BrowseMsg,"Windows NT 4.0") then
SystemCheck="Windows NT 4.0"
else if inStr(BrowseMsg,"Windows NT 5.0") then
SystemCheck="Windows NT 2000"
else
SystemCheck="未知类型"
end if
end if
end if
end Function
'由于时间的原因我没有写判定win95和windows xp的语句,感兴趣的网友可以
'自行添加:)
'+++++++++++结束+++++++++++
if inStr(BrowseMsg,"MSIE") then
SystemVersion=CInt(Mid(BrowseMsg,inStr(BrowseMsg,"MSIE")+5,1))
response.write "您的浏览器的版本是 IE"&BrowseVersion&"
"
response.write "您的操作系统是 "&SystemCheck()
end if
%>
----------------------------------------
ok,enjoy it and good luck!
-----------------------------------------
首先她要用到asp的ServerVarialbles这个集合。在ServerVarialbles有这样一项HTTP_USER_AGENT,他有什么作用呢?他的作用就是获取客户端浏览器的基本信息和操作系统的版本阿,如是什么牌子的浏览器阿(一般就是IE和netscape了),他们的版本号什么的,下面我用一个程序来说明她的用法,文件命名为CheckBrowse.asp。
$U2 Forum rautinee原创$
$http://u2bbs.126.com$
'++++++++++++++以下是程序的正文+++++++++++++++++
>
<%
Dim BrowseMsg,BrowseVersion,SystemVersion
BrowseMsg=Request.ServerVariables("HTTP_USER_AGENT")
'+++++++++++一个基本判别操作系统的函数+++++++++++
Function SystemCheck()
if inStr(BrowseMsg,"Windows 98") then
SystemCheck="Windows 98"
else if inStr(BrowseMsg,"Windows NT 4.0") then
SystemCheck="Windows NT 4.0"
else if inStr(BrowseMsg,"Windows NT 5.0") then
SystemCheck="Windows NT 2000"
else
SystemCheck="未知类型"
end if
end if
end if
end Function
'由于时间的原因我没有写判定win95和windows xp的语句,感兴趣的网友可以
'自行添加:)
'+++++++++++结束+++++++++++
if inStr(BrowseMsg,"MSIE") then
SystemVersion=CInt(Mid(BrowseMsg,inStr(BrowseMsg,"MSIE")+5,1))
response.write "您的浏览器的版本是 IE"&BrowseVersion&"
"
response.write "您的操作系统是 "&SystemCheck()
end if
%>
----------------------------------------
ok,enjoy it and good luck!
-
下一个: 一个分离中文英文的函数。
相关文章
- VBS 批量Ping的项目讲解 09-19
- 如何封装一个Ajax函数介绍 09-16
- ASP实现加法验证码方法 09-16
- ASP错误捕获的几种常规处理方法介绍 09-16
- ajax实现城市三级联动的代码介绍 09-16
- asp中获取日期为星期几的技巧 09-14