ckeditor 使用手册

CKEditor使用手册

在使用CKEditor过程中遇到了一些问题,现把它整理成手册,以便随时翻阅. 在页面<head>中引入ckeditor核心文件ckeditor.js <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
需要新建实例,假若CKEditor实例已存在
if (CKEDITOR.instances['textarea_name'])
{
    CKEDITOR.instances['textarea_name'].destroy();
}
CKEDITOR.replace('textarea_name');
function loadEditor(id)
{    
var instance = CKEDITOR.instances[id];
    if(instance)
    {        
     CKEDITOR.remove(instance);
    }
    CKEDITOR.replace(id);
}
var instance = CKEDITOR.instances['test'];
  if (instance)
{
  CKEDITOR.remove(CKEDITOR.instances['test']);
}  
if(CKEDITOR.instances[editorName])
delete CKEDITOR.instances[editorName];
CKEDITOR.replace(editorName);
获取CKEditor的值
var editor=CKEDITOR.replace( 'editor1' );
editor.document.getBody().getText(); //取得纯文本
editor.document.getBody().getHtml(); //取得html文本
CKEDITOR.instances.content.getData()=="")
content是textarea的name 设置CKEditor的值 CKEDITOR.instances.content.setData("CCCTO");
var editor = CKEDITOR.replace("content"); editor.setData("CCCTO");
插入内容 CKEDITOR.instances.message.insertHtml('')
原文地址:https://www.cnblogs.com/qiyongliang/p/3895374.html