UserAgents on Internet Explorer (registry workaround)


To totally unlock this section you need to Log-in


Login

About the User-Agent String

The User-Agent (or UA) string is sent along in the headers of every HTTP request so the server knows what type of browser is making the request.

When you visit a webpage, your browser sends the user-agent string to the server hosting the site that you are visiting. This string indicates which browser you're using, its version number, and details about your system, such as operating system and version. The web server can use this information to provide content that is tailored for your specific browser.

Because certain non-Microsoft sites add details to the user-agent string, it's important to understand the user-agent string. Here we'll explain the user-agent string, list the values from recent Internet Explorer versions, and document registry keys that modify the user-agent string.

Your UserAgent

For example, your actual useragent is the following:

[usera]

Understanding the user-agent string

When you request a webpage, your browser sends a number of headers to the server hosting the site that you're visiting, as shown here.

GET / HTTP/1.1

Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko
Accept-Encoding: gzip, deflate
Proxy-Connection: Keep-Alive
Host: microsoft.com

These headers occur during a negotiation process that helps the browser and the hosting server determine the best way to provide the requested information. The user-agent header identifies the application requesting the information from the server, typically a browser. This identification string is called the user-agent string and contains tokens that provide specific details about the program making the request. Tokens vary among programs; the tokens in the Internet Explorer user-agent string describe the browser, the operating system, and the current browser mode.

Starting with IE11, the user-agent string was updated to be more consistent with other popular browsers.

TokenDescription
Mozilla/5.0Application name and version. For historical reasons, Internet Explorer identifies itself as a Mozilla browser.
compatibleCompatibility flag token. It indicates that Internet Explorer is compatible with a set of common features.
MSIE 9.0The Version token identifies the browser and contains the version number, as reported by the current browser mode. The example value indicates Windows Internet Explorer 9.
Windows NT 6.1The Platform token identifies the operating system and version. The example token indicates Windows 7.
Trident/5.0The Trident token identifies the version of MSHTML (Trident) and can be used to determine whether or not the webpage is displayed in Compatibility View.

User-agent registry keys

When you install certain third-party programs or Windows components, such as the Microsoft .NET Framework or Windows XP SP2, feature tokens are added to the user-agent string. This is done by adding tokens to the following registry keys.

UserAgents on Internet Explorer (registry workaround)

The Pre-Platform and Post-Platform keys contain values whose names appear before and after the Platform token, respectively. For example, if a string value is added to the Post-Platform key, the name appears after the platform token in the user-agent string. Multiple tokens added to either key appear in an unpredictable order.

Earlier versions of Internet Explorer included feature tokens defined using the Pre-Platform and Post-Platform keys part of the user-agent string during the HTTP negotiation process. Over time, this lead to overly long user-agent strings, which in turn created problems for certain web servers. Problems usually appeared when user-agent strings were longer than 256 characters.

As of Internet Explorer 9, the user-agent string no longer includes feature tokens during HTTP negotiation. Feature tokens are included in the value returned by the userAgent property of the navigator object. Applications that rely on the earlier behavior should be modified accordingly.

You can also override certain tokens of the user-agent string by adding values to the following registry key.

UserAgents on Internet Explorer (registry workaround)

The default value of the User Agent key replaces the application name and application version tokens reported in the user-agent string. Be aware that the first seven characters are used for the application name, and the remaining characters specify the application version token.

The Compatible, Platform, and Version values replace the corresponding tokens in the user-agent string. Additional tokens can be added to the user-agent string by using the Registry Editor to create new string values under the Pre-Platform key or Post-Platform key. The value name should be the complete token; the value data is ignored.

Tokens added to the Pre-Platform key appear before the platform token in the final user-agent string. Tokens added to the Post-Platform key appear after the platform token in the final user-agent string. Multiple tokens in either the Pre-Platform key or Post-Platform key are displayed in an unpredictable order.

Parsing the User-Agent String

The most common way to detect Internet Explorer is to use client-side scripting to parse the user-agent string and extract the version number from the version token. The following example shows the preferred way to do this with JavaScript.

function getInternetExplorerVersion()

// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
var rv = -1; // Return value assumes failure.
if (navigator.appName == 'Microsoft Internet Explorer')
{
var ua = navigator.userAgent;
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if (re.exec(ua) != null)
rv = parseFloat( RegExp.$1 );
}
return rv;
}
function checkVersion()
{
var msg = "You're not using Internet Explorer.";
var ver = getInternetExplorerVersion();
if ( ver > -1 )
{
if ( ver >= 8.0 )
msg = "You're using a recent copy of Internet Explorer."
else
msg = "You should upgrade your copy of Internet Explorer.";
}
alert( msg );
}

As you review this example, please note the following:

A regular expression extracts the version number from the user-agent version token. Regular expressions let you specify optional conditions to match, so that you can match a larger number of version tokens, not just those that match a strict set of conditions.

The version number extracted from the version token is formally converted to a numeric value. Care must be taken because pre-release versions of Internet Explorer typically add letters to the version token. For example, the version token for pre-release versions of Internet Explorer 7 was "MSIE 7.0b".

The checkVersion() function verifies that the browser is version 8.0 or later. This ensures that the welcome message is displayed for those using newer versions of the browser.

This example properly detects most versions of Internet Explorer, but only if scripting is enabled. However, the user-agent string is dynamic; it can be changed by the end user, by browser extensions, and by operating system updates. As a result, there's no guarantee that the user-agent string accurately reflects the browser being used. The next sections show techniques that may be more effective alternatives.

Using Conditional Comments

If you are specifically interested in Internet Explorer, conditional comments might be a more appropriate choice. The following example shows an effective way to use conditional comments to display custom content.

<!--[if gte IE 8]>

<p>You're using a recent version of Internet Explorer.</p>
<![endif]-->
<!--[if lt IE 7]>
<p>Hm. You should upgrade your copy of Internet Explorer.</p>
<![endif]-->
<![if !IE]>
<p>You're not using Internet Explorer.</p>
<![endif]>

Like the earlier JavaScript example, this example makes sure the current version is greater than or equal to a specified version number. This ensures that the content designed for the current version of the browser is properly displayed in a future version.

This example carefully combines downlevel-revealed and downlevel-hidden conditional comments to ensure that each message appears only for the intended browsers.

Because conditional comments do not rely on JavaScript, they are effective even if the user has disabled scripting. Unlike the user-agent string, conditional comments are typically updated when the browser is upgraded.

Detecting Features

For many Web sites, detecting a browser's features is the preferred form of browser detection because it allow the Web developer to focus on the general capabilities of a browser, rather than the specific details of each browser release. The following example demonstrates a simple form of feature detection.

if (XMLHttpRequest)

{
// This browser implements this feature.
}

Feature detection tends to support a broader range of browsers. In addition, should a browser implement the feature you're interested in, your content will be delivered without requiring changes to your browser detection technique.

As a result, techniques that focus on features tend to require less maintenance than techniques that rely on environmental factors, such as the user-agent string. In addition, they tend to work across a wider variety of browser devices, including screen readers, mobile devices, and so on.

Want Internet Explorer to simulate another version?

Through Registry Editor we can simulate another version of our browser (IE):

  • Internet Explorer 6 on WindowsXP (use this to workaround sites that block IE7 or Windows Vista)
  • Internet Explorer 7 on your current OS.
  • Internet Explorer 7 on Vista.
  • Internet Explorer 8 on Vista (use this to workaround sites that block Windows 7).
  • Internet Explorer 9.
  • Undo User-Agent registry overrides.

You can download all the registry keys with the following below link.

Download

NOTE: to download windefend.reg you'll have to register or login on HeelpBook. Sorry for the inconvenience.

[wpfilebase tag="file" id=170 /]