Can I turn on IE 10 Compatibility View using JavaS

2019-04-21 20:56发布

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?

2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-21 21:34

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.

查看更多
Animai°情兽
3楼-- · 2019-04-21 21:41

You say “I just added the following meta tag within the header tag”. Do you mean:

  1. The <header> tag
  2. The <head> tag?

The x-ua-compatible meta tag does need to go inside the <head> tag, not a <header> tag.

查看更多
登录 后发表回答