Online HTML Editor Kindeditor-4.1.10 simple example

Source: Internet
Author: User

Kindeditor is a set of open source HTML visual editor, mainly used for users to get WYSIWYG editing results on the site, compatible with IE, Firefox, Chrome, Safari, opera and other mainstream browsers. : http://www.kindsoft.net/down.php

file directories after extracting files such as:Among them, ASP, ASP. NET, JSP and PHP folder is a background processing program, examples is a presentation file, can be deleted according to their own needs after uploading to their own server. The next step is to invoke Kindeditor, which implements the online HTML editing function on the page. The first step is to add the text field textarea to the form that needs to call the editor, and as the carrier for the Kindeditor implementation, the sample code is as follows:
1 < Textareaid = "editor_id" name = "Content" style = "width:700px;height:300px;" > 2 what is displayed by default 3 </ textarea >   
The second step is to introduce the Kindeditor JS file. Since Kindeditor is written in JS, before initializing the editor, the Kindeditor JS file must be introduced, and the sample code for the introduction of the method is as follows:
1 <  charset= "Utf-8"  src= "/Your directory/kindeditor.js"></  Script>2<charset= "Utf-8"  src  = "/Your directory/lang/zh_cn.js"></script>
The third step, initialize the Kindeditor editor, initializes the example as follows:
1 <script>2 kindeditor.ready (function(K) {3 window.editor = K.cre Ate (' #editor_id '); 4 }); 5 </script>   
Note:id must be a unique value on the current page.
Fourth step, get the HTML data in Kindeditor. The Kindeditor visualization is performed on the newly created IFRAME, and the TextArea box in code mode is newly created, so you need to perform sync () to set the HTML data to the original textarea before committing to the final commit. The sample code is as follows:
1<script>2     //Get HTML content3HTML =editor.html ();4 5     //after synchronizing textarea["#editor_id"] and kindeditor data, you can get the value of textarea directly, otherwise the values of textarea are empty or the default value6     Editor.sync ();7     //Select one of the following methods to get the HTML data to Kindeditor8Html=document.getelementbyid (' editor_id '). Value;//Native API9Html=k (' #editor_id '). Val ();//kindeditor Node APITenhtml=$ (' #editor_id '). Val ();//jquery//Set HTML content editor.html (' HTML content '); One</script>
Reference content:1. Kindeditor:Http://kindeditor.net/docs/usage.html

Online HTML Editor Kindeditor-4.1.10 simple example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.