2015-12-07 31 views
0

不工作这是我的代码到目前为止已经实现的CKEditor在IE11

<div class="CommentBox" style="display: none;"> 
    <div class="editor-field"> 
    @Html.TextAreaFor(model => model.ObjComment.Description, new { @id = "txtComment", @class = "clsCKEditor" }) 
    </div> 
</div> 

而jQuery代码如下:

$("#btnComment").click(function() {   
     var editor = CKEDITOR.instances[txtComment]; 
     if (CKEDITOR) { 
      if (CKEDITOR.instances.txtComment) { 
       CKEDITOR.instances.txtComment.destroy(); 
      } 
     } 
     $("#txtComment").val(''); 
     CKEDITOR.replace('txtComment', { uiColor: '#D8D8D8' }); 

     CKEDITOR.config.htmlEncodeOutput = true; 
     $(".CommentBox").show("slow");   
    }); 

这里,txtComment是文字区域的id,这将我正在使用编辑器。点击按钮后,将生成编辑器,并显示包含此编辑器的div。

这和Chrome和Firefox中的预期一致。但是,它在IE11中给出的错误在这一行:

var editor = CKEDITOR.instances[txtComment];**'txtComment' is undefined** 

Ami错过了什么?你能帮我解决这个问题吗?提前致谢。

回答

0

因为你没有使用editor变好,所以该行是无用的,您可以删除该行。

与行的问题是,你要使用一个名为txtComment变量,而不是字符串"txtComment"

+0

更改txtComment为“txtComment”工作。非常感谢。 – user2645738

0

我在IE11上发现了一些javascript和Ajax错误,通过将它放在页面的Head部分,您告诉IE11进入兼容模式。这解决了我的问题。