在IE 8中不创建Ckeditor实例

时间:2013-01-31 12:27:39

标签: jquery jsp ckeditor

我在使用Spring Framework的java项目中使用Ckeditor版本4.0.1最新版本。在我的jsp页面中,我已经包含了主要的js文件,如下所示

<script type="text/javascript" src="<c:url value="./ckeditor/ckeditor.js"/>" ></script>

在使用textarea的jsp页面中,我创建了一个这样的实例。

<textarea cols="100" rows="4" id="detailedwriteup" name="detailedwriteup" >${hotel.detailedwriteup}</textarea></div>

<script type="text/javascript">

   var instance = CKEDITOR.instances['detailedwriteup'];
   if(instance){
       CKEDITOR.remove(instance);
   }


    CKEDITOR.replace( 'detailedwriteup',
        {
         width: 900
        });

</script>

在IE 9中,它在IE 9中运行良好,但问题出现在IE8上。在IE8中,没有创建ckeditor实例。

任何我遇到的解决方案。

先谢谢。

1 个答案:

答案 0 :(得分:1)

您的示例代码永远不会起作用,因为您在实例检查后实例化CKEditor。

尽管回答你的问题 - &gt; 始终使用instanceReady-event

<textarea cols="100" rows="4" id="detailedwriteup" name="detailedwriteup" >${hotel.detailedwriteup}</textarea>

<script type="text/javascript">

   CKEDITOR.on('instanceReady', function (event) {
        instance = event.editor;
        if (instance) {
            instance.destroy();
        }
    });


    CKEDITOR.replace( 'detailedwriteup',
        {
         width: 900
        });

</script>