在使用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/oolee/archive/2012/11/09/ck.html
相关资源:CKEditor 3.6.2中文文档