Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: innerText Property Gives Incorrect Result with contentEditable Property


View products that this article applies to.

Symptoms

If the contentEditable attribute of a PRE tag on element is set to TRUE, the innerText property does not behave as expected. If you insert line breaks in the text that is inside the PRE tag and then use the innerText property to retrieve the text, you notice that it does not include the line breaks. You may experience this behavior with Microsoft Internet Explorer 5.5 Service Pack 2 when you install the security updates that come with the Microsoft Knowledge Base article 313675, or with later cumulative updates.

↑ Back to the top


Resolution

To resolve this problem, install the following security update for Microsoft Internet Explorer 5.5 Service Pack 2.

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

Steps to Reproduce the Behavior

  1. Paste the following code in Microsoft Notepad and then save it as Test.htm:
    <HTML>
    <SCRIPT type="text/javascript">
    function showText()
    {
      alert("!!" + document.getElementById("div1").innerText+ "!!");
    }
    </SCRIPT>
    <BODY>
    <DIV id="div1" name="div1" contentEditable="true">
    <PRE id='pre1'  style='margin:0px;'>
    Press enter anywhere in this text and press the button.
    </PRE>
    </DIV>
    <INPUT type="button" value="Button" id=button1 name=button1 onclick="showText()">
    </BODY></HTML>
  2. In Internet Explorer, locate Test.htm.
  3. Put the pointer in the middle of the text line and then press ENTER. The line breaks as expected. Click the button.
The result that you expect is for a message box to display the text as it appears in the browser with line breaks that break the text in two. However, after you install Internet Explorer 5.5 SP2 and patch Q313675, the message box displays the text in a single line without any line breaks.

↑ Back to the top


Keywords: KB811037, kbfix, kbdhtml, kbmshtml, kbinetdev

↑ Back to the top

Article Info
Article ID : 811037
Revision : 4
Created on : 11/5/2003
Published on : 11/5/2003
Exists online : False
Views : 415