【问题标题】:CKEditor not working in IE11CKEditor 在 IE11 中不起作用
【发布时间】:2016-03-11 17:25:16
【问题描述】:

这是我目前实现的代码

<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**

阿米错过了什么?请你帮我解决这个问题。提前致谢。

【问题讨论】:

    标签: jquery asp.net asp.net-mvc-3 ckeditor


    【解决方案1】:

    您可以删除该行,因为您根本没有使用 editor 变量,因此该行没有用。

    该行的问题在于您尝试使用名为 txtComment 的变量,而不是字符串 "txtComment"

    【讨论】:

    • 将 txtComment 更改为“txtComment”有效。非常感谢。
    【解决方案2】:

    我在使用 IE11 时遇到了一些 javascript 和 Ajax 错误,将其放在页面的 Head 部分中,您是在告诉 IE11 进入兼容模式。这解决了我的问题。

    【讨论】:

      猜你喜欢
      • 2018-10-25
      • 2019-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 2018-10-19
      • 2023-03-09
      相关资源
      最近更新 更多