Override intranet compatibility mode IE8

后端 未结 19 2059
执念已碎
执念已碎 2020-11-22 10:04

By default IE8 forces intranet websites into compatibility mode. I tried changing the meta header to IE8, but it doesn\'t acknowledge the meta header and just uses the brows

19条回答
  •  渐次进展
    2020-11-22 10:08

    I had struggled with this issue and wanted to help provide a unique solution and insight.

    Certain AJAX based frameworks will inject javascripts and stylesheets at the beginning of the and doing this seems to prevent the well-established meta tag solution from working properly. In this case I found that directly injecting into the HTTP response header, much like Andras Csehi's answer will solve the problem.

    For those of us using Java Servlets however, a good way to solve this is to use a ServletFilter.

    public class EmulateFilter implements Filter {
    
    @Override
    public void destroy() {
    }
    
    @Override
    public void doFilter(ServletRequest arg0, ServletResponse arg1,
            FilterChain arg2) throws IOException, ServletException {
        HttpServletResponse response = ((HttpServletResponse)arg1);
        response.addHeader("X-UA-Compatible", "IE=8");
        arg2.doFilter(arg0, arg1);
    }
    
    @Override
    public void init(FilterConfig arg0) throws ServletException {
    }
    
    }
    

提交回复
热议问题