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

女生的网名这么多〃 提交于 2019-12-10 02:44:53

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/13641503/can-i-turn-on-ie-10-compatibility-view-using-javascript-or-html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!