【问题标题】:ckeditor not loading in IE when used in two applications在两个应用程序中使用时,ckeditor 未在 IE 中加载
【发布时间】:2016-11-15 17:17:53
【问题描述】:

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

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

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

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

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

IE 中的超时继续进行,但 CKEDITOR 对象永远不可用。

代码:

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”不可用。会不会是反缓存设置导致 IE 加载出现问题?

加载过程中的错误信息:

“错误:无效参数。\n 在匿名函数 (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:431)\n 在匿名函数 (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:153)\n 在匿名函数 (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:78)\n 在全局代码 (http://domain.com/includes/ckeditor/ckeditor.js?anti-cache=09Jun2016&=1468730100637:5:2)”

【问题讨论】:

  • 请提供您正在使用的 HTML,如果可能的话,请提供一个可以证明问题的有效小提琴。

标签: javascript internet-explorer ckeditor


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-11
      • 2012-01-15
      • 1970-01-01
      • 1970-01-01
      • 2018-07-15
      • 2013-09-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多