BrowserInformation Class
Provides general information about the browser, such as name, version, and operating system.
Namespace: System.Windows.Browser
Assembly: System.Windows.Browser (in System.Windows.Browser.dll)
The BrowserInformation type exposes the following members.
| Name | Description | |
|---|---|---|
|
BrowserVersion | Gets the version of the browser technology that the current browser is based on. |
|
CookiesEnabled | Gets a value that indicates whether the browser supports cookies. |
|
Name | Gets the name of the browser technology that the current browser is based on. |
|
Platform | Gets the name of the browser operating system. |
|
ProductName | Gets the product name of the browser. |
|
ProductVersion | Gets the product version number of the browser. |
|
UserAgent | Gets the user agent string of the browser. |
| Name | Description | |
|---|---|---|
|
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
|
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
|
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
|
GetType | Gets the Type of the current instance. (Inherited from Object.) |
|
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
|
ToString | Returns a string that represents the current object. (Inherited from Object.) |
This class corresponds to the Navigator object of the browser. It is accessed through the HtmlPage class.
The following table lists Silverlight BrowserInformation members and their corresponding JavaScript functions.
|
BrowserInformation property |
JavaScript function |
|---|---|
|
Navigator.appName |
|
|
Navigator.appVersion |
|
|
Navigator.userAgent |
|
|
Navigator.platform |
|
|
Navigator.cookieEnabled |
|
|
Values are extracted from Navigator.userAgent |
The following example demonstrates how the BrowserInformation class provides browser information.
using System; using System.Windows.Controls; using System.Windows.Browser; public class Example { public static void Demo(System.Windows.Controls.TextBlock outputBlock) { outputBlock.Text += "\nSilverlight can provide browser information:\n" + "\nBrowser Name = " + HtmlPage.BrowserInformation.Name + "\nBrowser Version = " + HtmlPage.BrowserInformation.BrowserVersion.ToString() + "\nUserAgent = " + HtmlPage.BrowserInformation.UserAgent + "\nPlatform = " + HtmlPage.BrowserInformation.Platform + "\nCookiesEnabled = " + HtmlPage.BrowserInformation.CookiesEnabled.ToString() + "\nProductName = " + HtmlPage.BrowserInformation.ProductName.ToString() + "\nProductVersion = " + HtmlPage.BrowserInformation.ProductVersion.ToString(); } }
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.