Egregious IE Bug
After nearly a decade of battling Internet explorer, you would have thought I knew all of IE's quirks, but today I stumbled across a "feature" (read bug) which absolutely astounded me. Running the code below in IE 7 or 8 shows their implementation of innerHTML strips leading spaces from the DOM. This wreaks havoc on HTML editors such as TinyMCE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>XHTML Page</title>
</head>
<body>
<div id="baseDiv">
<a id="link" href="#" onclick="helloWorld()">Say hi...</a>
</div>
<script type="text/javascript">
//<!--<![CDATA[
function helloWorld() {
var newSpan = document.createElement('span');
newSpan.innerHTML = ' hello world ';
prompt('', newSpan.outerHTML);
}
//]]>-->
</script>
</body>
</html>












