<< February 2010 | Home | April 2010 >>

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>
Social Bookmarks :  Add this post to Slashdot    Add this post to Digg    Add this post to Reddit    Add this post to Delicious    Add this post to Stumble it    Add this post to Google    Add this post to Technorati    Add this post to Bloglines    Add this post to Facebook    Add this post to Furl    Add this post to Windows Live    Add this post to Yahoo!

Export this post as PDF document  Export this post to PDF document