繁体   English   中英

CKEditor在IE11中不起作用

[英]CKEditor not working in 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是我用作编辑器的textarea的ID。 单击该按钮时,将生成编辑器,并显示包含该编辑器的div。

可以在Chrome和Firefox中正常运行。 但是,它在IE11中在此行给出了错误:

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

阿美有什么东西吗? 您能帮我解决这个问题吗? 提前致谢。

我在IE11中遇到了一些JavaScript和Ajax错误,并将其放在页面的“头”部分中,这是在告诉IE11进入兼容模式。 这解决了我的问题。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM