简体   繁体   English

CKEditor在IE11中不起作用

[英]CKEditor not working in IE11

This is the code i've implemented so far 这是我到目前为止已实现的代码

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

And the JQuery code is as follows: 并且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");           
    });

Here, txtComment is an id of the textarea which i'm using as an Editor. 在这里,txtComment是我用作编辑器的textarea的ID。 On click of the button, the editor will be generated and the div containing this editor will show up. 单击该按钮时,将生成编辑器,并显示包含该编辑器的div。

This is working perfectly as expected in Chrome and Firefox. 可以在Chrome和Firefox中正常运行。 However,its giving error in IE11 at this line: 但是,它在IE11中在此行给出了错误:

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

Ami missing something? 阿美有什么东西吗? Would you please help me resolve this. 您能帮我解决这个问题吗? Thanks in advance. 提前致谢。

I had some javascript and Ajax errors with IE11 and by putting this in the Head section of your page you are telling IE11 to go into compatibility mode. 我在IE11中遇到了一些JavaScript和Ajax错误,并将其放在页面的“头”部分中,这是在告诉IE11进入兼容模式。 This solved my problem. 这解决了我的问题。

You can remove that line because you're not using the editor variable at all, so that line is useless. 您可以删除该行,因为根本没有使用editor变量,因此该行是无用的。

The problem with that line is that you're trying to use a variable named txtComment , instead of a string "txtComment" 该行的问题是,您尝试使用名为txtComment的变量,而不是字符串"txtComment"

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

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