主要防止加载同一个id,如下代码
- <span>
- <textarea cols="80" id="content2" name="content2" rows="10" >${email.content?default('')}</textarea>
- <script type="text/javascript">
- //添加ckeditor编辑器;
- var editor ;
- if(!CKEDITOR.instances.content2){ //判定content2是否存在
- editor= CKEDITOR.replace("content2");
- }else{
- addCkeditor("content2");
- }
- function addCkeditor(id){
- var editor2 = CKEDITOR.instances[id];
- if(editor2) editor2.destroy(true);//销毁编辑器 content2,然后新增一个
- editor = CKEDITOR.replace(id);
- }
- </script>
- </span>