如何以编程方式打开IE9的兼容性视图在Javascript [英] How to turn on IE9 Compatibility View programmatically in Javascript

查看:110
本文介绍了如何以编程方式打开IE9的兼容性视图在Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式打开IE浏览器的兼容性。

I need to turn on IE compatibility programmatically.

我知道这个工作在C#中:

I know this works in C# :

Page.Header.Controls.AddAt(0, new HtmlMeta { HttpEquiv = "X-UA-Compatible", Content = "IE=EmulateIE7" });

我的问题是我所有的窗口都显示在一个JS的功能:例如:

My problem is all my windows are displayed in a JS function: for instance:

function openRadWin(idAgir) {
    radopen("DemandesEnAttente_Estimate.aspx?id=" + idAgir, "RadWindow1");

}

所以我的问题是:有没有什么方法可以做到同样的事情在JS

So my question is : is there any ways to do the same thing in JS?

在此先感谢

推荐答案

据我所知,这是不可能的。您可以从JS,但设置检测兼容性模式它是不可能的我的知识。

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. 如果您使用的是在您的网站母版页,添加元头(< META HTTP-EQUIV =X-UA-Compatible的内容=IE = EmulateIE7> )。

  2. 要#1相似,如果您使用的是共同的基页类(良好和建议的做法),那么你可以从共同的基页的页眉元注入到所有网页。

  3. 最后,您可以使用IIS配置HTTP头添加到所有你的回应。

例如,对于IIS7 / IIS7.5,你可以使用的web.config

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>

我建议1号或2 - 如果你没有母版页或基页类,那么也许它是一个很好的时间来介绍两个

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.

这篇关于如何以编程方式打开IE9的兼容性视图在Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆