Library code snippets
Visitors' Browser Information
The information that is available to client-side scripts (ie JavaScript) regarding browser version, operating system etc. is also made available to ASP scripts. For example, to get the visitor's browser, you can use
Response.Write Request.ServerVariables("HTTP_USER_AGENT")
Below are some examples of the values that can be returned:
'Windows NT 4, IE 6
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 4.0)
'Windows 2000, IE 5.01
Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)
'Netscape 6.1, Windows 98
Mozilla/5.0 (windows; u; windows 98; en-us; rv:0.9.2) gecko/20010726 netscape6/6.1
'Opera, Windows 95
Mozilla/5.0 (windows 95; u) opera 5.01 [en]
Obviously, to determine the user's browser using code is not particularly straight forward. Obviously, you can check if it is IE by using
If InStr(1, Request.ServerVariables("HTTP_USER_AGENT"),"MSIE")
Then
'is Microsoft Internet Explorer
End If
However, retrieving any more detailed information is very difficult. Fortunately, Microsoft have the answer (!), with their Browser Capabilities component. This component reveals not only what make of browser it is, but whether it supports frames, vb script etc. Below is a simple example
<%
'Create an instance of the Browser Capabilities Component
Dim objBC
Set objBC = Server.CreateObject("MSWC.BrowserType")
%>
<b>Your browser:</b> <%=objBC.Browser%><br>
<b>Browser version:</b> <%=objBC.Version%><br>
<b>Support Frames?</B> <%=objBC.Frames%><br>
Having said that, it can't be entirely relied upon; it identifies my copy of
IE 6 as Netscape 4.0! (The Browser Capabilities component gets its information
from c:\winnt\system32\inetsrv\browscap.ini)
Related articles
Related discussion
-
Binary Studio | software development outsourcing Ukraine
by Soft Industry (5 replies)
-
asp Request.QueryString("dir")
by realmeteo (1 replies)
-
Looking for Senior Web Designer
by lwsmedia (0 replies)
-
Read eMails from Outlook express using ASP
by kumaravelu (1 replies)
-
Help to Call ASP function from onclick event in HTML to pass an array
by vka (0 replies)
Related podcasts
-
Scott Guthrie
Scott catches up with Scott Guthrie in an interview covering Ajax, Asp 2.0, extender controls, CSS adapters and more.
I've found browscap.ini updates for IE on MSDN. Does Netscape release anything to help us update our own ini files? Cyscapes version is outdated (obviously).
This thread is for discussions of Visitors' Browser Information.