Browser Capabilities

Browser Capabilities

HttpBrowserCapabilities

  • ASP.NET object to get information about the requesting client's browser capabilities: System.Web.HttpBrowserCapabilities browser = System.Web.HttpContext.Current.Request.Browser;
  • Code that can be used to get information about the requesting client's browser capabilities: Sitecore.Data.Items.DeviceItem device = Sitecore.Context.Device; Sitecore.Web.Configuration.DeviceCapabilities deviceCapabilities = device.Capabilities; System.Web.HttpBrowserCapabilities browser = deviceCapabilities.Browser;

Browser Capabilities C# Web Control Code

Sitecore.Data.Items.Item item = this.GetItem();
if (item == null) return;

//Sitecore API alternative to techniques described in Info section
System.Web.HttpBrowserCapabilities browser = Sitecore.Web.WebUtil.GetBrowserCapabilities();
if (browser == null) return;

string supportsJavaScript = "false";
if (browser.EcmaScriptVersion.Major >= 1)
    supportsJavaScript = "true";
         
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
//using : for colon and ? for question mark and   for space
output.Write("{0}: {1}", "Item", item.DisplayName);
output.RenderEndTag(); //P

output.Write("{0}&#58;&#160;{1}", "ActiveX Controls", "<b>" + browser.ActiveXControls.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "AOL Browser", "<b>" + browser.AOL.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Background Sounds", "<b>" + browser.BackgroundSounds.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Beta", "<b>" + browser.Beta.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Browser String", "<b>" + browser.Browser + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Browser Type ", "<b>" + browser.Type + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Browser Version ", "<b>" + browser.Version + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Is Browser", "<b>" + browser.IsBrowser(browser.Browser).ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Combine Forms In Deck", "<b>" + browser.CanCombineFormsInDeck.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Initiate Voice Call", "<b>" + browser.CanInitiateVoiceCall.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render After Input Or Select Element", "<b>" + browser.CanRenderAfterInputOrSelectElement.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render Empty Selects", "<b>" + browser.CanRenderEmptySelects.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render Input And Select Elements Together", "<b>" + browser.CanRenderInputAndSelectElementsTogether.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render Mixed Selects", "<b>" + browser.CanRenderMixedSelects.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render Onevent And Prev Elements Together", "<b>" + browser.CanRenderOneventAndPrevElementsTogether.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render Postback Cards", "<b>" + browser.CanRenderPostBackCards.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Render Setvar Zero With MultiSelectionList", "<b>" + browser.CanRenderSetvarZeroWithMultiSelectionList.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Can Send Mail", "<b>" + browser.CanSendMail.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Channel Definition Formatting", "<b>" + browser.CDF.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Client .NET Framework Version", "<b>" + browser.ClrVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Cookies Supported", "<b>" + browser.Cookies.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Is Crawler", "<b>" + browser.Crawler.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "DefaultSubmitButtonLimit", "<b>" + browser.DefaultSubmitButtonLimit.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "ECMA Script Version", "<b>" + browser.EcmaScriptVersion.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports HTML Frames", "<b>" + browser.Frames.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Gateway Major Version", "<b>" + browser.GatewayMajorVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Gateway Minor Version", "<b>" + browser.GatewayMinorVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Gateway Version", "<b>" + browser.GatewayVersion.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Has Back Button", "<b>" + browser.HasBackButton.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Hides Right Scrollbars", "<b>" + browser.HidesRightAlignedMultiselectScrollbars.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "HTML Text Writer", "<b>" + browser.HtmlTextWriter + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Browser ID", "<b>" + browser.Id.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Input Type", "<b>" + browser.InputType.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Color Display", "<b>" + browser.IsColor.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Is Mobile Device", "<b>" + browser.IsMobileDevice.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Java Applets", "<b>" + browser.JavaApplets.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "JScript Version", "<b>" + browser.JScriptVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Major Version", "<b>" + browser.MajorVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Maximum Rendered Page Size", "<b>" + browser.MaximumRenderedPageSize.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Maximum Softkey Label Length", "<b>" + browser.MaximumSoftkeyLabelLength.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Minor Version", "<b>" + browser.MinorVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Minor Version String", "<b>" + browser.MinorVersionString + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Mobile Device Manufacturer", "<b>" + browser.MobileDeviceManufacturer + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Mobile Device Model", "<b>" + browser.MobileDeviceModel.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Microsoft DOM Version", "<b>" + browser.MSDomVersion.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Number Of Soft Keys", "<b>" + browser.NumberOfSoftkeys.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Platform", "<b>" + browser.Platform + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Preferred Image Mime", "<b>" + browser.PreferredImageMime + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Preferred Rendering Mime", "<b>" + browser.PreferredRenderingMime + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Preferred Rendering Type", "<b>" + browser.PreferredRenderingType + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Preferred Request Encoding", "<b>" + browser.PreferredRequestEncoding + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Preferred Response Encoding", "<b>" + browser.PreferredResponseEncoding + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Renders Break Before Select And Input", "<b>" + browser.RendersBreakBeforeWmlSelectAndInput.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Renders Breaks After Html Lists", "<b>" + browser.RendersBreaksAfterHtmlLists.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Renders Breaks After Wml Anchor", "<b>" + browser.RendersBreaksAfterWmlAnchor.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Renders Breaks After Wml Input", "<b>" + browser.RendersBreaksAfterWmlInput.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Renders Wml DoAccepts Inline", "<b>" + browser.RendersWmlDoAcceptsInline.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Renders Wml Selects As Menu Cards", "<b>" + browser.RendersWmlSelectsAsMenuCards.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Attribute Colon Substitution", "<b>" + browser.RequiresAttributeColonSubstitution.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Content Type Meta Tag", "<b>" + browser.RequiresContentTypeMetaTag.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Control State In Session", "<b>" + browser.RequiresControlStateInSession.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Double Byte", "<b>" + browser.RequiresDBCSCharacter.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Html Adaptive Error Reporting", "<b>" + browser.RequiresHtmlAdaptiveErrorReporting.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Leading Page Break", "<b>" + browser.RequiresLeadingPageBreak.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires No Break In Formatting", "<b>" + browser.RequiresNoBreakInFormatting.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Output Optimization", "<b>" + browser.RequiresOutputOptimization.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Phone Numbers As Plain Text", "<b>" + browser.RequiresPhoneNumbersAsPlainText.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Special Viewstate Encoding", "<b>" + browser.RequiresSpecialViewStateEncoding.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Unique File Path Suffix", "<b>" + browser.RequiresUniqueFilePathSuffix.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Unique HTML Checkbox Names", "<b>" + browser.RequiresUniqueHtmlCheckboxNames.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires Unique HTML Input Names", "<b>" + browser.RequiresUniqueHtmlInputNames.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Requires URL Encoded Post Field  Values", "<b>" + browser.RequiresUrlEncodedPostfieldValues.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Screen Bit Depth", "<b>" + browser.ScreenBitDepth.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Screen Characters Height", "<b>" + browser.ScreenCharactersHeight.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Screen Characters Width", "<b>" + browser.ScreenCharactersWidth.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Screen Pixels Height", "<b>" + browser.ScreenPixelsHeight.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Screen Pixels Width", "<b>" + browser.ScreenPixelsWidth.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Access Key Attribute", "<b>" + browser.SupportsAccesskeyAttribute.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Body Color", "<b>" + browser.SupportsBodyColor.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Bold", "<b>" + browser.SupportsBold.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Cache Control Meta Tag", "<b>" + browser.SupportsCacheControlMetaTag.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Callback", "<b>" + browser.SupportsCallback.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports CSS", "<b>" + browser.SupportsCss.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports DIV Align", "<b>" + browser.SupportsDivAlign.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports DIV No Wrap", "<b>" + browser.SupportsDivNoWrap.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Empty String in Cookie Value", "<b>" + browser.SupportsEmptyStringInCookieValue.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Font Color", "<b>" + browser.SupportsFontColor.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Font Name", "<b>" + browser.SupportsFontName.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Font Size", "<b>" + browser.SupportsFontSize.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Image Submit", "<b>" + browser.SupportsImageSubmit.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports IMode Symbols", "<b>" + browser.SupportsIModeSymbols.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports InputI Style", "<b>" + browser.SupportsInputIStyle.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Input Mode", "<b>" + browser.SupportsInputMode.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Italic", "<b>" + browser.SupportsItalic.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "Supports JavaScript", "<b>" + supportsJavaScript + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports JPhone Multimedia Attributes", "<b>" + browser.SupportsJPhoneMultiMediaAttributes.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports JPhone Symbols", "<b>" + browser.SupportsJPhoneSymbols.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Query String In Form Action", "<b>" + browser.SupportsQueryStringInFormAction.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Redirect With Cookie", "<b>" + browser.SupportsRedirectWithCookie.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Select Multiple", "<b>" + browser.SupportsSelectMultiple.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Uncheck", "<b>" + browser.SupportsUncheck.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports XML HTTP", "<b>" + browser.SupportsXmlHttp.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports Tables ", "<b>" + browser.Tables.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Supports VBScript", "<b>" + browser.VBScript.ToString() + "</b><br/>");
output.Write("{0}&#58;&#160;{1}", "W3C DOM Version", "<b>" + browser.W3CDomVersion.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Win16-based Computing Device", "<b>" + browser.Win16.ToString() + "</b><br/>");
output.Write("{0}&#63;&#160;{1}", "Win32-based Computing Device ", "<b>" + browser.Win32.ToString() + "</b>");

output.RenderEndTag(); //Div


Browser Capabilities C# Web Control Output

ActiveX Controls: False
AOL Browser: False
Background Sounds: False
Beta: False
Browser String: Chrome
Browser Type : Chrome37
Browser Version : 37.0
Is Browser? True
Can Combine Forms In Deck? True
Can Initiate Voice Call? False
Can Render After Input Or Select Element? True
Can Render Empty Selects? True
Can Render Input And Select Elements Together? True
Can Render Mixed Selects? True
Can Render Onevent And Prev Elements Together? True
Can Render Postback Cards? True
Can Render Setvar Zero With MultiSelectionList? True
Can Send Mail? True
Channel Definition Formatting: False
Client .NET Framework Version: 0.0
Cookies Supported: True
Is Crawler? False
DefaultSubmitButtonLimit: 1
ECMA Script Version: 3.0
Supports HTML Frames? True
Gateway Major Version: 0
Gateway Minor Version: 0
Gateway Version: None
Has Back Button? True
Hides Right Scrollbars? False
HTML Text Writer: 
Browser ID: chrome
Input Type: keyboard
Supports Color Display? True
Is Mobile Device? False
Java Applets: True
JScript Version: 0.0
Major Version: 37
Maximum Rendered Page Size: 300000
Maximum Softkey Label Length: 5
Minor Version: 0
Minor Version String: 0
Mobile Device Manufacturer: Unknown
Mobile Device Model: Unknown
Microsoft DOM Version: 0.0
Number Of Soft Keys: 0
Platform: WinNT
Preferred Image Mime: image/gif
Preferred Rendering Mime: text/html
Preferred Rendering Type: html32
Preferred Request Encoding: 
Preferred Response Encoding: 
Renders Break Before Select And Input? False
Renders Breaks After Html Lists? True
Renders Breaks After Wml Anchor? False
Renders Breaks After Wml Input? False
Renders Wml DoAccepts Inline? True
Renders Wml Selects As Menu Cards? False
Requires Attribute Colon Substitution? False
Requires Content Type Meta Tag? False
Requires Control State In Session? False
Requires Double Byte? False
Requires Html Adaptive Error Reporting? False
Requires Leading Page Break? False
Requires No Break In Formatting? False
Requires Output Optimization? False
Requires Phone Numbers As Plain Text? False
Requires Special Viewstate Encoding? False
Requires Unique File Path Suffix? False
Requires Unique HTML Checkbox Names? False
Requires Unique HTML Input Names? False
Requires URL Encoded Post Field Values? False
Screen Bit Depth: 8
Screen Characters Height: 40
Screen Characters Width: 80
Screen Pixels Height: 480
Screen Pixels Width: 640
Supports Access Key Attribute? True
Supports Body Color? True
Supports Bold? True
Supports Cache Control Meta Tag? True
Supports Callback? True
Supports CSS? True
Supports DIV Align? True
Supports DIV No Wrap? False
Supports Empty String in Cookie Value? True
Supports Font Color? True
Supports Font Name? True
Supports Font Size? True
Supports Image Submit? True
Supports IMode Symbols? False
Supports InputI Style? False
Supports Input Mode? False
Supports Italic? True
Supports JavaScript: true
Supports JPhone Multimedia Attributes? False
Supports JPhone Symbols? False
Supports Query String In Form Action? True
Supports Redirect With Cookie? True
Supports Select Multiple? True
Supports Uncheck? True
Supports XML HTTP? True
Supports Tables ? True
Supports VBScript? False
W3C DOM Version: 1.0
Win16-based Computing Device? False
Win32-based Computing Device ? True