Product Home Page | Developer Site | Version | |
This example shows some of the entries for Internet Explorer (IE) 5.0. Since it has no parent line, the only properties it has (other than those defined in the default section) are those explicitly defined:
[IE 5.0]
browser=IE
Version=5.0
majorver=#5
minorver=#0
frames=TRUE
tables=TRUE
cookies=TRUE
vbscript=TRUE
javascript=TRUE
ActiveXControls=TRUE
In the following example, IE 5.0 is specified as the parent for the browser. The properties explicitly provided will replace, or add to, those values in the parent's definition:
[Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)*]
parent=IE 5.0
platform=Windows 2000
version=5.0
minorver=01
[IE 5.0]
browser=IE
frames=TRUE
tables=TRUE
cookies=TRUE
backgroundsounds=TRUE
vbscript= TRUE
javascript= TRUE
. . .
To determine if a browser supports JavaScript, use the following code:
Set bc = Server.CreateObject("MSWC.BrowserType")
if bc.javascript = 0 then
Response.Write "This browser does not support JavaScript."
else
REM The browser supports JavaScript so simply continue.
end if
The following example determines if a browser supports tables:
Set bc = Server.CreateObject("MSWC.BrowserType")
if bc.tables = 0 then
Response.Write "This browser does not support tables."
. . .
The following example uses the Browser Capabilities component 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>JavaScript</td><td>
<% if (bc.javascript = TRUE) then %> TRUE
<% else %> FALSE
<% end if %> </td></tr>
</table>
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.