oolxg

在使用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(\'\')

分类:

技术点:

相关文章:

  • 2021-12-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-11-18
  • 2021-11-18
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2021-07-23
  • 2021-11-18
  • 2022-12-23
  • 2022-02-03
  • 2022-12-23
  • 2021-11-05
相关资源
相似解决方案