以下是判斷瀏覽器是否為IE...
程式碼如下:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim hbc As HttpBrowserCapabilities = Request.Browser
Response.Write("瀏覽程式種類: " & hbc.Type & "<br/>") '假如是IE版本為8就會顯示IE8
Response.Write("瀏覽程式名稱: " & hbc.Browser & "<br/>") '假如是IE就顯示IE
'IndexOf字串搜尋,假如有找到IE就會>-1,否則等於-1
If hbc.Browser.ToUpper().IndexOf("IE") >= 0 Then
Response.Write("瀏覽器是IE瀏覽器" & "<br/>")
Else
Response.Write("瀏覽器為" & hbc.Browser & "<br/>")
End If
Response.Write("版本: " & hbc.Version & "<br/>")
Response.Write("主版本: " & hbc.MajorVersion & "<br/>")
Response.Write("次版本: " & hbc.MinorVersion & "<br/>")
Response.Write("平台: " & hbc.Platform & "<br/>")
Response.Write("支援框架: " & hbc.Frames & "<br/>")
Response.Write("支援表格: " & hbc.Tables & "<br/>")
Response.Write("支援Cookies: " & hbc.Cookies & "<br/>")
Response.Write("支援VBScript: " & hbc.VBScript & "<br/>")
Response.Write("支援Java Applets: " & hbc.JavaApplets & "<br/>")
Response.Write("支援ActiveX控制項: " & hbc.ActiveXControls & "<br/>")
End Sub
執行結果如下:
參考:
http://blog.blueshop.com.tw/kenqpqp/archive/2006/03/29/20517.aspx
http://msdn.microsoft.com/zh-tw/library/system.web.configuration.httpcapabilitiesbase.browser(v=vs.90).aspx#Y500
沒有留言:
張貼留言