到目前为止,这是我实现的代码
<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**阿美漏掉了什么吗?你能帮我解决这个问题吗。提前谢谢。
发布于 2015-12-07 19:23:14
您可以删除该行,因为您根本没有使用editor变量,因此该行是无用的。
这一行的问题是,您试图使用名为txtComment的变量,而不是字符串"txtComment"
发布于 2015-12-07 14:48:52
我在IE11中出现了一些javascript和Ajax错误,通过将其放在页面的头部分,您将告诉IE11进入兼容性模式。这解决了我的问题。
https://stackoverflow.com/questions/34127982
复制相似问题