欲取得目前和服务器联机之浏览器的信息,可以使用Browser 属性。Browser 属性是一个集合对象,所以也可以使用一个HttpBrowserCapabilities 型态的对象变量来接收Browser 属性的传回值。下列范例我们使用HttpBrowserCapabilities 型态的变量来取得了浏览器的部分信息:
<Html>
<Script Language="VB" Runat="Server">
Sub Page_Load(Sender As Object,e As Eventargs)
Dim bc As HttpBrowserCapabilities = Request.Browser
Response.Write("<p>浏览器信息:</p>")
Response.Write("浏览器= " & bc.Browser & "<br>")
Response.Write("型态= " & bc.Type & "<br>")
Response.Write("名称= " & bc.Browser & "<br>")
Response.Write("版本= " & bc.Version & "<br>")
Response.Write("使用平台= " & bc.Platform & "<br>")
Response.Write("是否为测试版= " & bc.Beta & "<br>")
Response.Write("是否为16 位的环境= " & bc.Win16 & "<br>")
Response.Write("是否为32 位的环境= " & bc.Win32 & "<br>")
Response.Write("是否支持框架(Frame) = " & bc.Frames & "<br>")
Response.Write("是否支持表格(Table) = " & bc.Tables & "<br>")
Response.Write("是否支持Cookie = " & bc.Cookies & "<br>")
Response.Write("是否支持VB Script = " & bc.VBScript & "<br>")
Response.Write("是否支持Java Script = " & bc.JavaScript & "<br>")
Response.Write("是否支持Java Applets = " & bc.JavaApplets & "<br>")
Response.Write("是否支持ActiveX Controls = " & bc.ActiveXControls &
"<br>")
End Sub
</Script>
</Html>
使用Netscape 浏览的结果:
文章来源于领测软件测试网 https://www.ltesting.net/