What is UEditor
Recently, I used Baidu's rich text editor in the project. There are detailed operation process documents on the official website. Here I just record some events that are often used in projects. In order to facilitate future queries.
UEditor is an open source project of Baidu's javascript editor. It supports Php, Asp, Asp.Net and Jsp background configurations. What is recorded here is the writing method of Asp. For details, please refer to the official website for detailed documents.
Official website transmission: https://ueditor.baidu.com/website/
Reference to UEditor
First, download the latest version https://ueditor.baidu.com/website/download.html#ueditor
Secondly, reference ueditor.config.js and ueditor.all.js in the required interface
1 <!DOCTYPE HTML> 2 <html lang="en-US"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <title>ueditor demo</title> 7 </head> 8 9 <body> 10 <!-- Load the editor's container --> 11 <script id="container" name="content" type="text/plain"> 12 Here is your initialization content 13 </script> 14 <!-- configuration file --> 15 <script type="text/javascript" src="ueditor.config.js"></script> 16 <!-- Editor source file --> 17 <script type="text/javascript" src="ueditor.all.js"></script> 18 <!-- Instanced editor --> 19 <script type="text/javascript"> 20 var ue = UE.getEditor('container'); 21 </script> 22 </body> 23 24 </html>
Then, set up and read the contents of the editor
1 ar ue = UE.getContent(); 2 //The best way to operate the editor is in the editor ready Then do it again. 3 ue.ready(function() { 4 //Set the contents of the editor 5 ue.setContent('hello'); 6 //Obtain html Content, returning: <p>hello</p> 7 var html = ue.getContent(); 8 //Get plain text content, return: hello 9 var txt = ue.getContentTxt(); 10 });
Finally, check whether the rich text editor has entered information.
1 var IsHas = ue.hasContents(); 2 if (IsHas == false) { //by false When the content is empty.} 3 else if (IsHas == true) { //by false Time content is not empty. }