A fun day with IE8

I had a previous post describing how to export html to excel/pdf with angularjs and servlet(spring mvc)

When our qa was testing in IE8, the whole thing does not work. Spent almost a day to figure out all the issues:

IE8 does not work with Angularjs 1.3

I was previously using Angualrjs 1.3.2. Now I have to downgrade to 1.2.28.

IE8 Iframe  cannot append element

Basically i got:

‘ error:unexpected call to method or property access’

when trying to append my form to the hidden iFrame.

It turns out in IE8, you cannot append element to the iframe before the iframe is explicitly appended to the dom. So i have to change the order of appending: body.append(iframe) first, then iframe.append(form).

IE8 does not send parent url as referrer from iFrame

We have some referrer check on the server side, my rest call fails due to lack of referrer. You can overcome this either by manually adding referrer OR just change the server side code to ignore REST paths.

 does not give you xhtml when innerHTML() is called

This is hilarious! when you call innerHTML of an element, IE8 will remove the surrounding quotes of ‘class’ if it only contains 1 classname. For example: class=”ng-binding” becomes class=ng-binding. This may looks trivial, but for flying sourcer which uses iText as rendering engine, XHTML is required!  Hence I have to use jTidy to clean the html to the Xhtml:

        Tidy tidy = new Tidy();
        // we do not need the DocType which would cause error(in iText) which is due to the Struts' dependency on xalan 2.5.1
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        tidy.parseDOM(new ByteArrayInputStream(sb.toString().getBytes(Charsets.UTF_8)), outputStream);

        String xhtmlResult = outputStream.toString();

Since our app is still using Struts1 as server side mvc, i have to omit the DocType, otherwise the xalan 2.5.1 will complain.

NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.

You can also exclude it in the POM’s Struts dependency and use the new version of xalan.

IE8 cannot download file without explicitly set Pragma header or remove it

I tested the download in the IE9 using IE8 mode. But when it comes to real IE8, The following error pops up :

IE : Unable to download * from *. Unable to open this Internet site. The requested site is either unavailable or cannot be found

It turns out you have to remove the Pragma:nocache from the header or change it to something else like cache/token… So

Solution 1: remove the ‘pragma’ header and set the ‘Cache-Control: no-store, no-cache, must-revalidate’

Solution 2: set the pragma to cache/token or anything other than no-cache and set the  Cache-Control:private’ .This allows certain caching and might not fit with your security needs, then use solution 1.

ie1 ie2 ie3


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s