[英]How to turn on IE9 Compatibility View programmatically in Javascript
I need to turn on IE compatibility programmatically. 我需要以编程方式打开IE兼容性。
I know this works in C# : 我知道这在C#中有效:
Page.Header.Controls.AddAt(0, new HtmlMeta { HttpEquiv = "X-UA-Compatible", Content = "IE=EmulateIE7" });
My problem is all my windows are displayed in a JS function: for instance: 我的问题是我所有的窗口都显示在JS函数中:例如:
function openRadWin(idAgir) {
radopen("DemandesEnAttente_Estimate.aspx?id=" + idAgir, "RadWindow1");
}
So my question is : is there any ways to do the same thing in JS? 所以我的问题是:在JS中有什么方法可以做同样的事情?
Thanks in advance 提前致谢
AFAIK, this is not possible. AFAIK,这是不可能的。 You can detect the compatibility mode from JS but setting it is not possible to my knowledge.
您可以从JS中检测到兼容模式 ,但据我所知无法进行设置。
As for as your problem goes, typically you can use few solutions: 至于问题所在,通常您可以使用几种解决方案:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
) in the master page. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
)。 For example, for IIS7/IIS7.5, you can use web.config 例如,对于IIS7 / IIS7.5,可以使用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. 我建议使用#1或#2-如果您没有母版页或基础页类,那么也许是介绍两者的好时机。
You could try adding this HTML tag to the top of any page that requires compatibility: 您可以尝试将此HTML标签添加到任何需要兼容性的页面的顶部:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
That way you shouldn't need a JavaScript solution. 这样,您就不需要JavaScript解决方案。 Of course, if you have the ability to change the HTML, then the best solution would be to fix the page so it doesn't require backwards compatibility.
当然,如果您具有更改HTML的能力,那么最好的解决方案是修复页面,使其不需要向后兼容。
I believe that the only way to influence headers from the client side is when you request a page using an XmlHttpRequest. 我相信影响客户端标头的唯一方法是使用XmlHttpRequest请求页面时。 It doesn't make sense to me to talk about modifying headers after the page has loaded, which is in effect what you are asking.
对我来说,谈论在页面加载后修改标头没有意义,这实际上是您要的内容。
What your C# example does, is add the following meta tag to the html page: 您的C#示例所做的是在HTML页面中添加以下meta标签:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
If you do this manually on the page that runs the JS code, it should work. 如果您在运行JS代码的页面上手动执行此操作,则它将正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.