The Browser Capabilities component creates a BrowserType object that provides your scripts with a description of the capabilities of the client's Web browser.
When a browser connects to the Web server, it automatically sends a User Agent HTTP header. This header is an ASCII string that identifies the browser and its version number. The BrowserType object compares the header to entries in the Browscap.ini file.
If it finds a match, the BrowserType object assumes the properties of the browser listing that matched the User Agent header.
If the object does not find a match for the header in the browscap.ini file, it takes on the default browser properties. If the object does not find a match and default browser settings have not been specified in the browscap.ini file, it sets every property to the string "UNKNOWN".
You can add properties or new browser definitions to this component simply by updating the browscap.ini file.
browscap.dll | The Browser Capabilities component. |
browscap.ini | A text file that maps browser capabilities to the HTTP User Agent header. This file must be in the same directory as browscap.dll. |
Set BrowserType = Server.CreateObject("MSWC.BrowserType")
None.
The following example uses the BrowserType object to display a table showing some of the capabilities of the current browser.
<% Set bc = Server.CreateObject("MSWC.BrowserType") %>
<table border=1>
<tr><td>Browser</td><td> <%= bc.browser %>
<tr><td>Version</td><td> <%= bc.version %> </td></TR>
<tr><td>Frames</td><td>
<% if (bc.frames = TRUE) then %> TRUE
<% else %> FALSE
<% end if %> </td></TR>
<tr><td>Tables</td><td>
<% if (bc.tables = TRUE) then %> TRUE
<% else %> FALSE
<% end if %> </td></TR>
<tr><td>BackgroundSounds</td><td>
<% if (bc.BackgroundSounds = TRUE) then %> TRUE
<% else %> FALSE
<% end if %> </td></TR>
<tr><td>VBScript</td><td>
<% if (bc.vbscript = TRUE) then %> TRUE
<% else %> FALSE
<% end if %> </td></TR>
<tr><td>JScript</td><td>
<% if (bc.javascript = TRUE) then %> TRUE
<% else %> FALSE
<% end if %> </td></TR>
</table>