Ckeditor/fckeditor use CKEditor 3.0.1 quick Use tutorial (with Insert Picture) _ Page Editor

Source: Internet
Author: User
Because the content directly as a string to the editor's Value property assignment using JavaScript code, to let JS code is not subject to the content of double quotes, line change, and so on interference, only first read into the textarea most convenient.

Using CKEditor 3.0.1
Copy Code code as follows:

<textarea cols= "rows=" id= "content" name= "content" >cftea</textarea>
<script type= "Text/javascript" src= "Ckeditor/ckeditor.js" ></script>
<script type= "Text/javascript" >
<!--
Ckeditor.replace ("content");
-->
</script>

It can be seen that the 3.x version of the use of very convenient, do not worry about the formation of two of the same name content. It is also possible to omit the ID of the textarea, because CKEditor first finds it by name, finds it, and then finds it by ID.

And the editor replaces the original textarea in the textarea position.

Set editor skin, width and height
Copy Code code as follows:

<textarea cols= "rows=" id= "content" name= "content" >cftea</textarea>
<script type= "Text/javascript" src= "Ckeditor/ckeditor.js" ></script>
<script type= "Text/javascript" >
<!--
Ckeditor.replace ("Content",
{
Skin: "Kama", width:700, height:300
});
-->
</script>

The skin value should be a folder name under the Ckeditor/skins folder, and the editor will not appear if you point to a nonexistent skin.

Setting values, taking values

Setting values

CKEDITOR.instances.content.setData ("cloud-dwelling community"); Content is the first parameter value of the previous Ckeditor.replace
Or
Copy Code code as follows:

var editor = ckeditor.replace ("content");
Editor.setdata ("cloud-dwelling community");

Take value

Alert (CKEDITOR.instances.content.getData ()); Content is the first parameter value of the previous Ckeditor.replace
Or

var editor = ckeditor.replace ("content");
Alert (Editor.getdata ());
Insert Picture

To demonstrate this example, it is best to put it in the button's event handler for some delay.

CKEDITOR.instances.content.insertHtml ("<img src=...>");

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.