Domanda

I'm working on a WebCenter Spaces application and have observed some strange behaviour in the course of cross-browser testing:

When visiting the site with Internet Explorer 8, Spaces quite plausible inserts this meta tag:

<meta http-equiv="X-UA-Compatible" content="IE=8.0">

When visiting it with Internet Explorer 9, compatibility view enabled, however, the following tag is added:

<meta http-equiv="X-UA-Compatible" content="IE=7.0">

This enforces that compatibility view is actually used. To add insult to injury, an alert dialog pops up informing the user that compatibility view must be disabled to use the application.

When compatibility view is disabled, Spaces sends a tag that does absolutely nothing in this case:

<meta http-equiv="X-UA-Compatible" content="IE=9.0">

Why isn't this tag sent to IE9 on general principle? This would then disable compatibility mode and render the page correctly, or not? How can I customize WebCenter Spaces to support IE9 properly?

Version info: Currently using WebCenter 11.1.1.6, but we're going to migrate to 11.1.1.5 (don't ask) - I'm testing with IE9 on Windows Server 2008 R2 Standard x64.

È stato utile?

Soluzione

It's sad but ADF do adds X-UA-Compatible tag based on MSIE property in User-Agent header. As far as I know, the only way to override this behavior is to use servlet filter. In which you can determine IE engine version by Trident property in User-Agent and set an appropriate X-UA-Compatible tag. We successfully used the following code for servlet filter:

public void doFilter(ServletRequest request, ServletResponse response, 
        FilterChain filterChain) throws IOException, ServletException {

    HttpServletRequest httpReq = (HttpServletRequest)request;
    String ua = httpReq.getHeader("User-Agent");

    Pattern patternEngineIE = Pattern.compile(".*Trident/(\\d).*");
    Matcher mEngineIE = patternEngineIE.matcher(ua);

    if (mEngineIE.find()) {
        int versionEngineIE = Integer.parseInt(mEngineIE.group(1));
        switch (versionEngineIE) {
        case 4:
            ua = ua.replaceAll("MSIE 7.0", "MSIE 8.0");
            response.addHeader("X-UA-Compatible", "IE=8");
            break;
        case 5:
            ua = ua.replaceAll("MSIE 7.0", "MSIE 9.0");
            response.addHeader("X-UA-Compatible", "IE=9");
            break;
        case 6:
            ua = ua.replaceAll("MSIE 7.0", "MSIE 10.0");
            response.addHeader("X-UA-Compatible", "IE=10");
            break;
        }
    }

    httpReq.addHeader("User-Agent", ua);
    filterChain.doFilter(httpReq, response);
}

Thus, we determine IE version by Trident property, which is 4 for IE8, 5 for IE9, even for compatibility mode. But in compatibility mode IE8 and IE9 add MSIE 7.0 property which we replace to MSIE 8.0 or MSIE 9.0 based on engine version.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top