I'm having trouble working with the HTML editor. We use "contentEditable" to implement it, however, when the paragraph formatting option is executed without the selected content, IE removes the identifier from one of the divs on the page.
The problem is repeating for me with HTML,
- just save it to a file,
- then open it in IE
- enable jscript on request
- press the button
- check for two message boxes
- the first one says "MainContents = object"
- the second says "MainContents = NULL"
I am using IE 6.0.2900.5512 with XP SP3
And is this repeated for you?
What's happening?
<html> <head> </head> <body id="BODY"> <div contentEditable="true" id="EDITBOX"> </div> <div id="MAINCONTENTS" unselectable="on"> <button title="Ordered List" unselectable="on" onclick='alert("MainContents = " + document.getElementById("MAINCONTENTS")); document.execCommand("InsertOrderedList"); alert("MainContents = " + document.getElementById("MAINCONTENTS")); '> Push Me </button> </div> </body> </html> <script type="text/javascript"> document.getElementById("EDITBOX").focus(); </script>
Background I work for an ISV that sells software to corporations, all of our customers currently use IE, and there is no market dependence for supporting other browsers. I was asked to implement an HTML editor using contentEditable. All formatting options are based on document.execCommand (), for example. document.execCommand ("bold");
Due to licensing restrictions (LGPL is not pleasant) and / or cost it is very difficult to get permission to use a third-party HTML editor. It took us a while to register to allow jquery.
I have an editor that works separately from the case of the paragraph formatting command when the user does not have the selected items. The HTML I posted is a small piece of HTML that I wrote in order to reproduce the problem I encountered.
see also http://www.maconstateit.net/tutorials/JSDHTML/JSDHTML12/jsdhtml12-02.htm and the Danger of using contentEditable in IE
javascript html internet-explorer internet-explorer-6
Ian Ringrose Feb 09 '09 at 11:59 2009-02-09 11:59
source share