Using Client Capabilities

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

Client capabilities consist of information about a client's browsing environment, such as screen resolution, screen dimensions, color depth, CPU, or connection speed. Web applications use this information to improve a user's experience by customizing content based on the capabilities that the client browser supports. For example, in response to a request from a browser application that is running on a handheld device with a 2" x 3" display, a server can reformat a Web page that was originally designed for a 24" diameter display to a format that is easier to view on the smaller display.

Although you can obtain client capabilities by using cookies, this approach is inefficient, because it requires repeated communication between the client and the server. This must then generate a custom page for each client request. In Internet Explorer 6 for Windows Embedded CE for Windows Embedded CE, client capabilities are exposed as default DHTML behaviors of the browser, through the clientCaps Behavior object. In response to a client request for a page, the server sends the page, together with a client-side script for obtaining the necessary information. In addition to providing information about the client browser, the clientCaps object provides a means of installing browser components on demand.

The following table shows the client capabilities that can be determined through the clientCaps behavior object in Internet Explorer 6 for Windows Embedded CE.

Property DHTML implementation Description

availHeight

window.screen.availHeight

Retrieves the height of the working area of the system's screen, excluding the Windows taskbar

availWidth

window.screen.availWidth

Retrieves the width of the working area of the system's screen, excluding the Windows taskbar

bufferDepth

window.screen.bufferDepth

Sets or retrieves the number of bits per pixel used for colors in the off-screen bitmap buffer

colorDepth

window.screen.colorDepth

Retrieves the number of bits per pixel used for colors on the destination device or buffer

height

window.screen.height

Retrieves the vertical resolution of the screen

width

window.screen.width

Retrieves the horizontal resolution of the screen

cookieEnabled

window.navigator.cookieEnabled

Retrieves whether client-side cookies are enabled in the browser

cpuClass

window.navigator.cpuClass

Retrieves a string that indicates the CPU class

platform

window.navigator.platform

Retrieves the name of the user's operating system

systemLanguage

window.navigator.systemLanguage

Retrieves the default language that is used by the system

userLanguage

window.navigator.userLanguage

Retrieves the current user language

Windows Embedded CE also provides limited support for two clientCaps object methods — getComponentVersion and isComponentInstalled. These methods can only:

  • Retrieve a component that is listed with its CLSID in the registry key [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\.
  • Accept references of type ComponentID. All other references return E_INVALIDARG.

Note

Because Internet Explorer for Windows Embedded CE does not support the downloading of ActiveX controls, there is no support for other clientCaps object methods.

The following code example shows how to use the clientCaps object to obtain information about client-side capabilities.

<SCRIPT>
<!--
function window.onload()
{
   sTempStr = "availHeight    = " + oClientCaps.availHeight    + "\n" + 
              "availWidth     = " + oClientCaps.availWidth     + "\n" + 
              "bufferDepth    = " + oClientCaps.bufferDepth    + "\n" +
              "colorDepth     = " + oClientCaps.colorDepth     + "\n" +
              "connectionType = " + oClientCaps.connectionType + "\n" +
              "cookieEnabled  = " + oClientCaps.cookieEnabled  + "\n" +  
              "cpuClass       = " + oClientCaps.cpuClass       + "\n" + 
              "height         = " + oClientCaps.height         + "\n" + 
              "javaEnabled    = " + oClientCaps.javaEnabled    + "\n" + 
              "platform       = " + oClientCaps.platform       + "\n" + 
              "systemLanguage = " + oClientCaps.systemLanguage + "\n" + 
              "userLanguage   = " + oClientCaps.userLanguage   + "\n" + 
              "width          = " + oClientCaps.width          + "\n" ;
  
   oPre.innerText = sTempStr;
}-->
</SCRIPT>

The following code example detects the number of colors available in the system, and assignsthe image with the appropriate number of colors to myImage.src. Therefore, if 256 colors or more are detected, it displays a 256-color bitmap. Otherwise, it uses a lower resolution 16-color bitmap.

<SCRIPT>
<!--
function window.onload()
{
   if (window.screen.colorDepth >= 8)
      myImage.src = "lanma256.bmp"   
   else
      myImage.src = "lanman16.bmp";
}
-->
</SCRIPT>
<!--In BODY block this HTML code displays the image. -->
<P><IMG ID="myImage" height="317" width="489" border="0" alt="Windows splash screen"></P>

See Also

Other Resources

Internet Explorer MSHTML/DHTML API Application Development
Internet Explorer 6 MSHTML/DHTML API