How to turn on IE9 Compatibility View programmatically in Javascript

AFAIK, this is not possible. You can detect the compatibility mode from JS but setting it is not possible to my knowledge.

As for as your problem goes, typically you can use few solutions:

  1. If you are using Master pages in your site, add the meta header (<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">) in the master page.
  2. Similar to #1, if you are using a common base page class (a good and recommended practice) then you can infuse the meta header from the common base page to all your pages.
  3. Lastly, you can use IIS configuration to add the http header to all your response.

For example, for IIS7/IIS7.5, you can use web.config

<system.webServer><httpProtocol><customHeaders><remove name="X-UA-Compatible"/><add name="X-UA-Compatible" value="IE=EmulateIE7"/></customHeaders></httpProtocol></system.webServer>

I would suggest #1 or #2 - in case you don‘t have master page or base page class then perhaps its a good time to introduce the both.

How to turn on IE9 Compatibility View programmatically in Javascript,布布扣,bubuko.com

How to turn on IE9 Compatibility View programmatically in Javascript

上一篇:C++之编译器与链接器工作原理


下一篇:[疑问] C# 多线程程序,如果在并行程序块中开空间会远远慢于将空间开在并行块之外