I have a JSF application with .xhtml pages running in intranet.I tried removing default meta tag and add the meta tag
<meta http-equiv="X-UA-Compatible" content="IE=8" />
But there is no use.Is this solution only for plain html pages or is there any other way using which i can programmatically disable compatibility mode.
If you want to prevent the compatibility mode for all your JSF pages you better use a filter for this:
Java
public class NoCompatibilityMode implements Filter {
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
ServletException {
if (((HttpServletRequest) req).getRequestURI().endsWith(".js.jsf")
|| ((HttpServletRequest) req).getRequestURI().endsWith(".css.jsf")) {
chain.doFilter(req, res);
} else {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("X-UA-Compatible", "IE=edge"); // No more Compatibility Mode
chain.doFilter(req, res);
}
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
}
web.xml
<filter>
<filter-name>NoCompatibilityMode</filter-name>
<filter-class>my.package.name.NoCompatibilityMode</filter-class>
</filter>
<filter-mapping>
<filter-name>NoCompatibilityMode</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
来源:https://stackoverflow.com/questions/22315643/to-programmatically-disable-ie-8-compatibility-mode-for-the-site-running-in-intr