I have a content editable
DIV
that plays the role of a rich text box.
<div id='myRichTextBox' contenteditable='true'>
</div>
I need to insert some images to this text box, I used function
execCommand
, Like this:
document.execCommand("insertImage", false, imgLink);
Once this function executed, It insert an element
<img src="imgLink">
to the text box.
But as we know a single tag in a standard HTML code must be either in the two following formats:
1. Start with
<TagName>
and ends with
</TagName>
2. Be in format
<TagName some attribute />
My problem is the inserted image element by the function
execCommand
is not in a standard format, And my XML parser fails with this HTML code.
How I can standard this HTML code? Please give me a solution.
Thanks in advance
abforce