Rich Text Editor, RTE for short, is a text editor embedded in a browser that is WYSIWYG.
The Rich Text Editor is different from the text editor. The better text editor is kindeditor and FCKeditor. The open-source Rich Text Editor ueditor launched by Baidu is one of the highlights. For browsers that support rich text editing, you can set the document designMode attribute to on and then execute document.exe ccommand ('commandname' [, uiflag [, value. Commandname and value can be found on msdn and MDC. They are the commands for creating various formats. For example, we need to bold the font and execute document.exe ccommand ('bold ', false. It's easy, right? However, it is worth noting that the command is executed only after the selected text is selected, and the selected text is formatted. For unselected text, different browsers have different processing methods. For example, ie may format the label content in the cursor, but other browsers do not process it, this is beyond the content of this article. Note that setting uiflag to true indicates display any user interface triggered by the Command (if any)
Differences between browsers 1. When Mozilla and IE generate HTML, Mozilla generates a span style, While IE generates a style using HTML tags: Mozilla
<span style="font-weight: bold;">I love geckos.</span>
<span style="font-weight: bold; font-style: italic;
text-decoration: underline;">Dinosaurs are big.</span>
IE
<STRONG>I love geckos.</STRONG>
<STRONG><EM><U>Dinosaurs are big.</U></EM></STRONG>
2. Another difference is that the access to documentmozilla in IFRAME uses the W3C standard iframeelement. contententie to use iframeelement.doc ument or directly use document.getelementbyid(aid).content{doc ument to obtain the document
The simplest editor example is provided here:
Eidtor.html
<! Doctype HTML> Eidtoriframe.html
<!DOCTYPE html>
Common command reference: https://developer.mozilla.org/en-US/docs/Web/API/document.execCommand
Principles of Rich Text Editor