IE compatibility mode forced in AJAX code
How to activate in my code : microsoft cpmpatibility mode : I would like, when a visitor come to my site to get his browser forced to b开发者_如何学Ce in compatibilty mode.
To force IE's compatibility mode, use the following in your page header:
<meta http-equiv="X-UA-Compatible" content="IE=7" />
This will force IE8 and above to render the page using IE7-compatibility mode. (You can also specify IE8-compatibility mode if you need that for IE9)
You can't change the compatibility mode from within your code after the page has loaded, so it can't be done using an ajax call; it has to be in the <header>
section of the main page load. (I mention this because you have ajax in your tags for the question).
Now that I've explained how to do it, I would like to add that it's generally considered a bad thing, unless you have a specific need for it. If a site is written in a way that means it doesn't work in a newer version of IE then it also probably doesn't work in other browsers. This indicates poor code, and it would probably be better to actually fix it than to apply the quick and easy way out of using the compatibility mode.
The only times when compatibility mode is recommended are when you are maintaining an existing web application based on an internal intranet where it won't be seen outside of the local network. In this case, compatibility mode can be helpful in making it possible to upgrade the browsers in the network without having to make large changes to the web apps.
But in an intranet environment, you can also control compatibility mode in the browser preferences, without having to use the meta tag.
Finally, you should also note that compatibility mode is not the same as running the old version of the browser. There are bugs and quirks in compatibility mode which do not appear in the real thing. It mostly works, but you should test thoroughly.
精彩评论