Reputation:
I need to turn on IE compatibility programmatically.
I know this works in 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:
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?
Thanks in advance
Upvotes: 1
Views: 21368
Reputation: 49185
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:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
) in the master page.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.
Upvotes: 6
Reputation: 42440
You could try adding this HTML tag to the top of any page that requires compatibility:
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
That way you shouldn't need a JavaScript solution. 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.
I believe that the only way to influence headers from the client side is when you request a page using an 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.
Upvotes: 1
Reputation: 916
What your C# example does, is add the following meta tag to the html page:
<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.
Upvotes: 1