ckeditor的使用与验证

 1、使id=id的textArea变为富文本编辑框

function inittextarea(id)
 {
  CKEDITOR.replace(id,{
         '600px',
         height:'300px',
         toolbar : [['Source','Save','NewPage','Preview','Templates','Cut','Copy','Paste','PasteText','PasteFromWord', 'SpellChecker','Scayt','Undo','Redo','Find','Replace','SelectAll','RemoveFormat','Form', 'Checkbox', 'Radio'],['TextField','Textarea','Select', 'Button', 'Bold','Italic','Underline','Strike','Subscript','Superscript','NumberedList','BulletedList','Outdent','Indent','Blockquote','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','Link','Unlink'],['Anchor','Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Styles','Format'],['Font','FontSize','TextColor','BGColor']]
     });
 }

2、ckeditor验证:

  

var editor=CKEDITOR.replace( 'editor1' )

或者

var oEditor2=CKEDITOR.instances[id];

然后使用如下语句就可以取得编辑器内的值。

editor.document.getBody().getText(); //取得纯文本

editor.document.getBody().getHtml(); //取得html文本

原文地址:https://www.cnblogs.com/qiyongliang/p/3922137.html