ASP 3.0高级编程(四)(2)
这将创建一个完整的URL包括端口号(这种情况下,不是标准值80)。例如,结果可能是:
http://194.74.60.254:1768/thispath/thispage.asp
检测浏览器的版本
ServerVariables集合中,另外一个有用的值是用户浏览器的用户代理字符串。在“Detecting the Browser Type”页
面(browsertype.asp),使用ServerVariables集合中的“HTTP_USER_AGENT”值来获得用户代理字符串,一些脚本用来解析该信息并寻找生产厂家名称和浏览器版本。
<%
strUA = Request.ServerVariables(“HTTP_USER_AGENT”)
Response.Write “The User Agent string is <B>” & strUA & “</B><P>”
If InStr(strUA, “MSIE”) Then
Response.Write “To upgrade your browser go to “_
& “<A HREF=” & Chr(34) & http://www.microsoft.com/ie/”_
& Chr(34) & “>http://www.microsoft.com/ie/<A></P>”
intVersion = Cint(Mid(strUA, InStr(strUA, “MSIE”) + 5, 1))
If intVersion >=4 Then
Response.Write “You can use Microsoft Dynamic HTML”
End If
Else
If InStr(strUA, “Mozilla”) Then
If InStr(strUA, “compatible;”) = 0 Then
Response.Write “Your browser is probably Navigator. You can “_
& “download the latest version of Navigator from “_