|
||
| Inside Technique : Backend Browser Detection : Capabilities Object The browser capabilities component is a server-side object. To use this component, you must call the Server object's CreateObject method. This
method instantiates and returns a reference to an object. To create the browser capabilities component, you need to call
CreateObject with the identifier "MSWC.BrowserType".
JScript
For those of you new to ASP scripting, you designate server scripts using special markup: <% ... %>. The contents within this markup are executed on the server and only results of the script, if any, are sent to the client. As we will demonstrate, the scripts contained within the block do not have to be executable by themself. Instead, all the script blocks on your page make up the program so you can end a script to embed HTML and then later continue with the script. We are going to start by testing the browser version. Most of our pages have three
logical paths: IE4, NS4, and other browsers. Therefore, we create 2 variables that represent whether
the user has a 4.0 or later browser and store that information in a variable: JScript
Now we have enough information to author browser specific pages. We
only provide the JavaScript version but you can easily convert this to VBScript:
Examine the above script closely. Notice how the script's execution ends to allow you to include some HTML, and then later continues. Each script block is executed sequentially in the page. If you were using IE4, the test for IE4 evaluates to true, the contents within the IE4 section are sent to the client, then the script continues executing. Since none of the other conditions are met, the other contents are skipped and not sent to the client. While in our pages we concentrate only on the browser brand and version, the browser capabilities component exposes additional properties for detecting support for tables, frames, ActiveX, scripting, and more. The set of capaibilities that you can test for are defined by the browser.ini file. This file is a user-customizable and updateable file that associates a set of properties and capabilities with a particular browser version. For more information on customizing the browser.ini file, we recommend you check out the information at Microsoft's web-site. Next, we continue with a few tips on client versus server-side detection. Page 1:Backend Browser Detection © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |