4th August 19:20
Possible bug in IE6.0?
I have discovered an extremely strange behavior with Internet Explorer while
programming an HTC component. At first I thought it is something related to
HTC and do***ent context or something, but then I tested it and made sure it
can be repeated any time.
<div id="editor" contentEditable="true" style="border: 1px solid
<input type="button" value="OL"
<input type="button" value="HTML" onclick="alert(do***ent.body.innerHTML);">
<input type="button" value="Test" onclick="alert(test.innerHTML);">
The error happens the moment you call execCommand("InsertOrderedList").
When you try writing text into the editable DIV, everything works fine.
However, when you click the OL button, which should insert an ordered list,
the HTML breaks apart!! In the example above, the <DIV id="test"> loses its
id attribute, and SPAN tag that is located within it gets dislocated and
suddenly appears outside of it! With the HTC I am writing I got ridiculous
results with my HTML code being copied all over the do***ent and similar.
If you try change <DIV id="test"> to <SPAN id="test">, everything works
This happens only when you call InsertOrderedList or InsertUnorderedList,
and only if you are starting a list on a first or last line of the entered
text. If you enter a few lines, and then position the cursor on a line in
the middle, and then call InsertOrderedList, everything works fine.
What I can be sure of, this is not a "by design" behavior ;-)