在两个应用程序中使用时,ckeditor 未在 IE 中加载

ckeditor not loading in IE when used in two applications

我有一个存储 ckeditor 的中心位置。

Header Web 应用程序在 IE、Firefox 和 Chrome 中成功使用 ckeditor。

Header 始终为域中的所有 Web 应用程序加载。

Web 应用程序 X 需要 ckeditor。 Web 应用程序等待(使用超时)CKEDITOR object 可用,然后使用它。

这适用于 Chrome 和 Firefox,但不适用于 IE。我在这里错过了什么?

IE 中的超时继续发生,但 CKEDITOR object 永远不可用。

代码:

namespace Models
{
    using System.ComponentModel.DataAnnotations;

    public class EmailModel
    {
        public int EmailID { get; set; }
        public string FromAddress { get; set; }
        public string ToAddresses { get; set; }

        [Required(ErrorMessage = "Subject is required.")]
        [StringLength(50, ErrorMessage = "Subject cannot be greater than 50 characters.")]
        public string Subject { get; set; }

        [Required(ErrorMessage = "Body is required.")]
        public string Body { get; set; }
    }
}

Html:

@model Models.EmailModel

@{
    ViewBag.Title = "Email Template Details";
}

<h2>Email Template Details</h2>

<script type="text/javascript" src="~/Scripts/EmailDetails.js?version=06.07.2016_1156"></script>

<div>
    <hr />
    <dl class="dl-horizontal">
        <dt>
            @Html.DisplayNameFor(model => model.FromAddress)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.FromAddress)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Subject)
        </dt>

        <dd>
            @Html.DisplayFor(model => model.Subject)
        </dd>

        <dt>
            @Html.DisplayNameFor(model => model.Body)
        </dt>

        <dd>
            @Html.HiddenFor(model => model.Body)
            <textarea id="editorBodyDetails" name="editorBodyDetails" style="display:none"></textarea>
        </dd>

    </dl>
</div>
<p>
    @Html.ActionLink("Edit", "Edit", new { id = Model.EmailID }) |
    @Html.ActionLink("Email Templates", "Index")
</p>

脚本:

var countCKEDITORAttemps = 0;

$(function () {

    initializeCKEDITOROnceLoaded(countCKEDITORAttemps);

});

function initializeCKEDITOROnceLoaded(countCKEDITORAttemps) {
    var interval = 1000; // ms
    if (countCKEDITORAttemps < 100) {
        window.setTimeout(function () {
            if (typeof(CKEDITOR) !== 'undefined') {
                setupCKEditor("editorBodyEdit");
            } else {
                countCKEDITORAttemps = countCKEDITORAttemps + 1;
                console.log("Loading CKEDITOR:" + countCKEDITORAttemps * 1000 + "milliseconds");
                window.setTimeout(initializeCKEDITOROnceLoaded(countCKEDITORAttemps), interval);
            }
        }, interval);
    }
}

function setupCKEditor(id) {
    CKEDITOR.replace(id, { height: 200, });
    CKEDITOR.instances[id].setData($("#Body").val());
}

注意:我没有在 Web 应用程序 X 中包含 ckeditor

ckeditor在IE中加载好像有问题的那一行在这里:

var b=d[c].src.match(a);

"src" 不可用。是否是 anticache 设置导致 IE 加载出现问题?

加载期间的错误消息:

"Error: Invalid argument.\n at Anonymous function (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:431)\n at Anonymous function (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:153)\n at Anonymous function (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:78)\n at Global code (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:2)"

我能够通过检查我的应用程序中加载的所有脚本来解决问题。加载脚本之一有问题,阻碍了在 IE 上加载 ckeditor。

您也可以通过更改应用程序中脚本的顺序来解决此问题。