首页 > 代码库 > ckeditor 使用手册
ckeditor 使用手册
CKEditor使用手册
在使用CKEditor过程中遇到了一些问题,现把它整理成手册,以便随时翻阅. 在页面<head>中引入ckeditor核心文件ckeditor.js <script type="text/javascript" src="http://www.mamicode.com/ckeditor/ckeditor.js"></script>
需要新建实例,假若CKEditor实例已存在
需要新建实例,假若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‘ );
获取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(‘‘)
插入内容 CKEDITOR.instances.message.insertHtml(‘‘)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。