Reputation: 11177
I'm having issues setting the IE compatibility mode in a website and various connected web apps and after much research on the subject I'm still a bit confused as to how this works. Basically I am working on a company website that is having issues when accessed via IE10 and am trying to set it to run in IE9 compatibility mode. There are many third party controls and various other elements of the site that are not working on IE10 and I don't have the time yet to update this site completely (it is a rather large site). Everything I have found has told me to set the compatibility mode by either adding code to the web config file or in a meta tag in the header. Seems easy enough.
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=9" />
</customHeaders>
</httpProtocol>
or
<meta http-equiv="X-UA-Compatible" content="IE=9">
Now when I set the compatibility mode manually (not in code but in my own browser) everything works fine and this is what I see via the IE developer tools.
Browser Mode: IE10 Compat View Document Mode: IE9 Standards
The issue here is that when I set this in my code, via one of the methods listed above, this is what I see and nothing seems to change.
Browser Mode: IE10 Document Mode: IE9 Standards
Notice that only the document mode is affected here, unlike when I make the change manually. As mentioned, I've done a lot of research on this and still don't quite understand the difference between browser mode and document mode or why the one I seemingly need to change is unaffected by the solution everyone seems to recommend here. Can anyone help me understand exactly what this means and what the point is, and more importantly does anyone know how to do what I am trying to accomplish here?
Upvotes: 2
Views: 2714
Reputation: 168655
IE doesn't allow you to programmatically set the Browser Mode
option. The X-UA-Compatible setting only sets Document Mode
, and there is no other setting you can use that works for Browser Mode
.
Fortunately, however, in most cases you shouldn't need to worry about the Browser Mode
anyway.
The Document Mode
is the one that changes the actual rendering engine; this is the important one for IE to display the content in IE9 mode.
Browser Mode
is much less important. All this does is set the User Agent string - ie the text that the browser sends to the server to identify what browser you're using. The actual rendering of the page is not affected by this setting.
So assuming your site doesn't do any server-side browser sniffing by looking at the User Agent string, then you really don't need to worry about Browser Mode
at all.
If you are doing browser sniffing, then it may affect you. If this is the case, then you are going to be a bit stuck since you can't force the browser to change mode, but in that case I would suggest you try a different technique. It's generally agreed that sniffing the User Agent string is a bad idea anyway, for a variety of reasons. In that case, you would likely be better off using client-side feature detection.
Hope that helps.
Upvotes: 4