DOCUMENT:Q224979 20-JUL-2001 [iis] TITLE :Using Browser Capabilities with Internet Explorer 5.0 PRODUCT :Internet Information Server PROD/VER:WINDOWS:5; winnt:5.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Internet Information Services version 5.0 - Microsoft Internet Explorer version 5 for Windows NT 4.0 ------------------------------------------------------------------------------- SUMMARY ======= Microsoft Internet Information Services (IIS) version 5.0 with Active Server Pages (ASP) and Internet Explorer provides enhanced client and server capabilities components that can be combined to allow Web developers greater control over the presentation of Web data to clients. This article explains how to combine these new features in a working example scenario. MORE INFORMATION ================ WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Client Capabilities in Internet Explorer ---------------------------------------- Microsoft Internet Explorer 4.0 introduced several client-side attributes to the DHTML Object Model (DOM) that can be used in customizing a page layout after it has been rendered for the client. Internet Explorer 5.0 takes this a step further by exposing this information as one of the browser's Default Behaviors. The following table is a partial list of useful client capabilities. (For a more complete list see the MSDN clientCaps Behavior page.) +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Client Capability | Description | DHTML Implementation | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | AvailHeight | Specifies the height of the working area of the system's screen, in pixels, excluding the taskbar. | Window.screen.availHeight | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | AvailWidth | Specifies the width of the working area of the system's screen, in pixels, excluding the taskbar. | Window.screen.availWidth | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | BufferDepth | Specifies the number of bits per pixel used for colors on the off- screen bitmap buffer. | Window.screen.bufferDepth | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | ColorDepth | Specifies the number of bits per pixel used for colors on the destination device or buffer. | Window.screen.colorDepth | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | CookieEnabled | Specifies whether client-side cookies are enabled in the browser. | Window.navigator.cookieEnabled | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | CpuClass | Specifies the type of CPU of the client computer. | Window.navigator.cpuClass | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Height | Specifies the vertical resolution of the screen, in pixels. | Window.screen.height | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | JavaEnabled | Specifies whether the Microsoft virtual computer is enabled in the browser. | Window.navigator.javaEnabled() | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Platform | Specifies the platform on which the browser is running. | Window.navigator.platform | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | SystemLanguage | Specifies the default language that the system is running. | Window.navigator.systemLanguage | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | UserLanguage | Indicates the current user language. | Window.navigator.userLanguage | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ | Width | Specifies the horizontal resolution of the screen, in pixels. | Window.screen.width | +----------------------------------------------------------------------------------------------------------------------------------------------------------+ Browser Capabilities in IIS --------------------------- IIS 5.0 adds server-side functionality by exchanging the client capabilities information through cookies and returning this information to an ASP page as part of the Browser Capabilities component. This allows Web developers that ability to write ASP code that is custom tailored for a client's display. Implementation -------------- Combining the Internet Explorer 5.0 and IIS 5.0 functionality into a single implementation can be thought of as a two-step process: 1. A DHTML page needs to be created to obtain the client capabilities and store them in cookies. a. The DHTML page needs to declare the clientcaps behavior.
availHeight = <%=objBrowserType.availHeight%>
availWidth = <%=objBrowserType.availWidth%>
d. The following example page illustrates all of the above steps. Copy this code and save it is "Clientcap.asp" on your IIS computer in the same Web folder as "Clientcap.htm." <%@LANGUAGE="VBSCRIPT"%>Attribute | Value |
---|---|
availHeight | <%=objBrowserType.availHeight %> |
availWidth | <%=objBrowserType.availWidth %> |
bufferDepth | <%=objBrowserType.bufferDepth %> |
colorDepth | <%=objBrowserType.colorDepth %> |
cookieEnabled | <%=objBrowserType.cookieEnabled %> |
cpuClass | <%=objBrowserType.cpuClass %> |
height | <%=objBrowserType.height %> |
javaEnabled | <%=objBrowserType.javaEnabled %> |
platform | <%=objBrowserType.platform %> |
systemLanguage | <%=objBrowserType.systemLanguage%> |
userLanguage | <%=objBrowserType.userLanguage %> |
width | <%=objBrowserType.width %> |
Welcome to the <%=UCase(objBrowserType.cpuClass)%> site!This site is dedicated to <%=UCase(objBrowserType.platform)%> issues. |