最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can I turn on IE 10 Compatibility View using JavaScript or HTML? - Stack Overflow

programmeradmin2浏览0评论

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?

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?

Share Improve this question edited Nov 30, 2012 at 13:17 Paul D. Waite 98.8k57 gold badges202 silver badges271 bronze badges asked Nov 30, 2012 at 8:31 ELAYARAJAELAYARAJA 5213 gold badges10 silver badges23 bronze badges 2
  • 3 what meta tag have you added ? – Ravi Y Commented Nov 30, 2012 at 8:33
  • i used only following code, – ELAYARAJA Commented Nov 30, 2012 at 12:06
Add a comment  | 

2 Answers 2

Reset to default 11

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.

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.

发布评论

评论列表(0)

  1. 暂无评论