0
votes

Setting document mode to a value other than the default isn't sending the according User-Agent header in requests (as seen in the network tab of IE devtools). However, executing navigator.userAgent, in the console, does reflect the appropriate string (associated to the document mode/user agent setting).

Is this a bug in IE dev tools? If not, what's the proper way to get IE to send the appropriate User-Agent header to the remote server?

1
i am expecting it to work accordingly :) - culturalanomoly
First mistake, it is IE, it never works accordingly :D But in all seriousness, if you want to test different versions of IE Use a program called IETester - MarshallOfSound
Are you setting just the "Document Mode"? Or are you setting the "Document Mode" and the "User Agent string" values? In order to change the User-Agent header request sent to the server, you must change the "User Agent string" value - Eric Tedj - MSFT
was tinkering with both settings and looking at the network tab; along with the console output of navigator.userAgent. we notice that in the network tab. both were different, console output displayed the "appropriate" user-agent string. though the network tab only reflected the change of the document mode ... - culturalanomoly
@MarshallOfSound IE still has a large user-base and this is a LOB app... not a mistake to support IE. understand your sentiment though. - culturalanomoly

1 Answers

0
votes

In JavaScript, document.documentMode maps to the F12 Developer Tools. The user agent is not affected:

Do:

Use the following detection methods to detect the source of errors more reliably and to make sure that your webpages are compatible across browsers:

Feature detection: Test whether a browser supports a feature before you use it. Feature detection enables cross-browser code to "just work" without requiring you to know the capabilities of every browser ahead of time. For example, the jQuery framework relies almost entirely on feature detection. For more info about how you can use jQuery's feature detection in your own site, see the jQuery.support documentation.
Behavior detection: Test for known issues before you apply a workaround. jQuery also uses behavior detection by running tests for known issues to determine if certain workarounds are needed.

Don't:

Detect specific browsers: Don't use the identity of a browser (for example, navigator.userAgent) to change a page's behavior. If you change code based on a specific browser, the page cannot easily adapt to changes and it might break when a new browser is released. In other situations, pages use a legacy workaround even when that workaround is no longer needed.
Assume unrelated features: Don't perform feature detection for one feature and then use a different feature. Sites that have this problem perform feature detection for one feature and then use other features without testing whether they are supported.

References