While building a blog similar to mine for a friend (running for a local political election), I stumbled on a bug, that's apparently been on this blog for quite some time. In the page with the list of comments for the last seven days, the AJAX code allowing users to open a post locally works, but in IE it trashes everything else on the page. The remaining text simply went away (the bug is now fixed, so you should not be able to see it).

After doing a little research I found the cause of the problem and I'm sharing it as it looks an interesting story. The JavaScript code in the page refreshes a placeholder tag with the following script:

document.getElementById('talkback_{id}').innerHTML = req.responseText; 

Where req.responseText is the result of the AJAX call. Now the original placehodler tag was created with XSLT, as anything else on this site, with this fragment:

        <span id="talkback_{id}">
           <!-- placeholder for message -->
        </span>

As the comment is for the XSLT only, it is removed while processing, and the tag (which has an ID taken from the "id" field of the current XML node) becomes empty. Now, looking for innerHtml on MSDN I found the following note: "By definition, elements that do not have both an opening and closing tag cannot have an innerHTML property." Ouch! This means that if the DOM node didn't have internal HTML at the beginning you cannot add any dynamically. So the fix was simply to add a non-breaking space (using the literal equivalent) to the node:

        <span id="talkback_{id}">&#160;
           <!-- placeholder for message -->
        </span>

Needless to say this used to work fine on Mozilla and other browser I tested it with, while it failed with IE7 (including the one in Windows Vista). HTML mysteries..

In any case, this problem of the closing tag is quite common in IE. For example you have a script tag in your HTML header with a final / and no closing </script>, IE fails to include the file. In too many cases IE treats a closed node (like <script />) differently from a node with a separate close (like <script></script>), which makes is hard to server XHTML to it... Firefox has its XHTML quirks as well, but IE has many more in my experience.