IE8 compatibility X-UA-Compatible java filter http-equiv GWT "links not working" broken EmulateIE7 compliance
Problem:
You're either certain your website/webapp is broken in IE8 or suspect it might be. What can you do?
For browsers such as firefox and IE7, you used the DOCTYPE switch to indicate if it should treat your page as being in "standards" mode or "quirks" mode. As discussed on A List Apart "standards" is open to interpretation and even if the page didn't fully comply with the standard it referenced, it could expect the browser to have a reasonable crack at letting it work.
Not any more. IE8 renders all pages in standards mode by default and it's interpretation is as far as I can tell, stricter than any other browser. In this mode, many HTML, CSS and javascript/DOM elements (that were introduced by older versions IE! - and in some cases understood by other browsers such as firefox) are not just deprecated, they're completely not there - meaning any reference to them will in most cases stop the page/application working in the browser. When this happens, the page layout may be askew, links may stop working and miscellaneous javascript errors will be flagged in the status bar.
If you're not sure if your webpage/webapp is strictly standards compliant, it most probably isn't.
GWT is effected - see Dan Moore's post and GWT Issue #3329.
Solution:
IE8 users can make broken pages work again by opting-out of the "most strict" standards treatment on a site-by-site basis using the "Compatibility View" button but you can save them the trouble by using a new http-header tag
X-UA-Compatible
. The A List Apart article above describes the merits of being able to target specific versions (and the comments seem to mostly disagree :) but in the majority of cases I imagine you just want the page to be treated the way IE7 did - "standards" mode (with "flexibility") for pages that require it and "quirks" mode for all others. So use the "IE=EmulateIE7" value by either:
- making the server side code add this http header to every response
X-UA-Compatible: IE=EmulateIE7
- or add the following meta tag to the
<head>
element of the page (which is essentially the equivalent to setting values on the http response)<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
You can cover the entire java web application by defining a filter as documented by Mark McLaren:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (response instanceof HttpServletResponse) { ((HttpServletResponse) response).setHeader("X-UA-Compatible", "IE=EmulateIE7"); } chain.doFilter(request, response); }
Apache hosted sites can be covered by using mod_headers. For example, assuming you have the module loaded, add the following to the httpd.conf file:
Header add X-UA-Compatible "IE=EmulateIE7"
Notes:
Having trouble installing the release version of IE8? (for goodness sake, just get firefox :) But, if you really do want to get it working for yourself see Internet Explorer 8 is not supported on this operating system for a discussion of common issues.
1 comment:
Fantastic! Thank you so much for this.
Post a Comment