Sunday, October 3, 2010

HTML page showing as blank in Internet Explorer after editing with Kompozer.

I am posting this solution in case it helps someone else.

The problem:
After editing a web page at work it all seemed fine to me, but a colleague could only see a blank page. He was using Internet Explorer 8. I had the same problem when I tested it in Internet Explorer 9. The page had always been designed and edited using Kompozer. The only change had been a move from WIndows XP to Windows 7 due to a computer failure. Looking at the source code it was clear that some rewriting had gone on, but the problem was not clear and I had to restore the page from a back up.

Now, this weekend I have had the same problem with a new version of my own web site. It validates with no errors but renders as a blank page in Internet Explorer.


The solution:
After a lot of debugging I have found the cause. IE9 stops rendering the page when it gets to the script tag in the head of the page that links to an external Javascript file. Kompozer has been rewriting the head elements with self-closing tags. This is fine in all the other lines, but the line linking to the external script file read:

<script language="JavaScript" src="filename.js"/>

This validates correctly and works in Chrome and Firefox, but it does not work in Internet Explorer or Safari for iPhone which both require the tag to be closed normally like this:

<script language="JavaScript" src="filename.js"></script>

The reason for this is that a self closing script tag is valid XHTML, and this is what Kompozer is editing for, but it is not valid HTML. If the web server is serving the web page as mime type "text/html", which is the norm, then IE will stop rendering the page when it sees the unrecognised self closed tag instead of just not loading the script file while loading the rest of the page. Internet Explorer was not originally designed to render XHTML at all but it does, because this is a real world necessity and other browsers fully support it even with a self closing script tag. This script tag issue seems to relate to a previous security issue with IE and it has caused it to behave differently from the other main browsers.

The reason this happened to me in the first place was that at home and work I had changed computers at work and home and installed fresh copies of Kompozer. I had downloaded the current development version from the 0.8 tree rather than the stable 0.7 one. It turns out that 0.8 has a bug where it is self closing the script tag even if you have typed it in with a normal closing tag. There appears to be no setting to override the  self-closing tag rewriting so the only solution is to uninstall Kompozer 0.8 and reinstall 0.7. After doing this I have had no problems and everything is back to normal.

No comments:

Post a Comment