Reputation: 521
How can I turn on IE 10 Compatibility View programmatically in Javascript or HTML?
I just added the following meta tag within the <head>
tag, but it is not working.
<meta http-equiv="x-ua-compatible" content="IE=EmulateIE7" >
Is there any way to do the same thing in JS?
Upvotes: 9
Views: 26280
Reputation:
I checked the compatibility mode article on msdn - here.
Your meta tag is still the method for enabling compatibility mode in IE 10 and IE 9.
As long as you have:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<!-- Other meta tags etc. -->
<head>
Then it should work. You could try making the http-equiv value case sensitive (at the moment you've set it to lowercase).
Also, to answer your question about JS, you can detect whether the browser is in compatibility mode by comparing the browser engine with the browser version for IE. However, this involves browser version detection, which tends to be a bit unreliable. Also, there isn't a way for you to set the user's compatibility mode in JS. So, for the moment at least, you'll have to stick with the meta tags.
I hope this helps.
A good plugin to allow you to view http header information is IEhttpheaders. Just download it from that link & install. Then, when you start IE, go to the tools menu and select 'DisplayIEhttpHeaders...'. When you visit your site it will list the header response. If you modify your answer to include the response, then we can see if it's the problem.
Upvotes: 11
Reputation: 98786
You say “I just added the following meta tag within the header tag”. Do you mean:
<header>
tag<head>
tag?The x-ua-compatible
meta tag does need to go inside the <head>
tag, not a <header>
tag.
Upvotes: 2