异步加载ckeditor 编辑器,注意事项:
第一.CKEDITOR 未定义:js未加载ckeditor.js
解决方案:
1.将 js文件放在父页面
<script src="http://www.cnblogs.com/../Content/ckeditor/ckeditor.js" type="text/javascript"></script>
<script src="http://www.cnblogs.com/../Content/ckeditor/ckfinder/ckfinder.js" type="text/javascript"></script>
2. 首次请求 生成编辑器,再次加载时,需要销毁上次生成的编辑器,重新 生成新的 编辑器
<textarea id="Content" rows="6" cols="10"></textarea> <script type="text/javascript"> jQuery(function () { // 300 弹窗高调 LoadCk(300); }); function LoadCk(hh) { //加载CKeditor //判定 Content 是否存在 var editor; if (!CKEDITOR.instances.Content) { var editor = CKEDITOR.replace('Content', { height: 300 }); } else { addCkeditor("Content", hh); } } //新增CKEDITOR function addCkeditor(id, hh) { var editor2 = CKEDITOR.instances[id]; //销毁编辑器 Content, 然后新增一个 if (editor2) editor2.destroy(true); editor = CKEDITOR.replace(id, { height: hh }); } </script>