0

我们正在使用以下代码(MVC Razor View)创建一个剑道窗口:

function openServerDetailsWindow(ServerName) {
    var serverDetailsWindow = $("#serverDetailsWindow");
    serverDetailsWindow.empty();
    serverDetailsWindow.append('@Html.Raw(String.Format("Loading Server Details...<br /><img src=\"{0}\" />", Url.Content("~/images/ajax_loader_wfred_bb0826.gif")))');

    var $urlpath = "@Url.Action("ServerDetails", "Server", new { serverName = "SERVERNAMEPLACEHOLDER", Printable = false })".replace("SERVERNAMEPLACEHOLDER", ServerName);

    if (!serverDetailsWindow.data("kendoWindow")) {
            serverDetailsWindow.kendoWindow({
                width: "1200px",
                height: "650px",
                modal: true,
                visible: false,
                title: "Application Name - Server Details-" + ServerName,
                actions: ["Refresh", "Maximize", "Close"],
                close: function (e) {
                    $(this.element).empty();
                },
                content: $urlpath
            });
    } else {
        serverDetailsWindow.data("kendoWindow").refresh({ url: $urlpath });
    }

    if (!serverDetailsWindow.data("kendoWindow")) {
        alert("Tried to open but serverDetailsWindow kendo data was not defined.");
    } else {
        //don't maximize the window! It prevents users from knowing it's a window and not a new page.
        serverDetailsWindow.data("kendoWindow").title("Application Name - Server Details - " + ServerName.toUpperCase());
        serverDetailsWindow.data("kendoWindow").center();
        serverDetailsWindow.data("kendoWindow").open();
    }
}

这个函数是从剑道网格中调用的,使用列模板,我们尝试了几种方法——它们都工作相同,在 IE-8 中出错,在 Chrome 中完美。

Option 1
    string ServerLink = Html.ActionLink("#=SERVER_NAME#", "", "", new { onclick = "openServerDetailsWindow('#=SERVER_NAME#');return false;" }).ToHtmlString();

Option 2
    string ServerClientTemplate = "<a href=\"\\#\" onclick=\"javascript:openServerDetailsWindow('#=SERVER_NAME#');\">#=SERVER_NAME#</a>";

我们在网站的数百个地方使用这两个代码块。大多数情况下,它在 IE-8 中运行良好,并且始终在 Chrome 中运行。在失败的页面上唯一显着的区别是带有链接的网格是通过 AJAX 引入的,而在它始终有效的页面上,网格是由 Razor 呈现的。我们无法理解为什么这很重要,或者为什么它只对 IE-8 很重要。

据我所知,它在较新版本的 IE 中完美运行。对不起,我们是一家大银行,我们无法升级 IE。我已经尝试禁止它-不会发生。

试过但没有用:

  • 在附加到文档正文的新 div 中创建窗口$(document.body).append("<div></div>")- 仅在 Chrome 中有效,IE 不会打开任何内容
  • 从函数返回 false
  • 设置标题、居中和打开的不同顺序(最后几行)
  • 将“var $urlpath”行“修复”为字符串(不能跨环境工作,无论如何都没有解决问题)
  • 审查了浏览器的差异 - 找不到任何重要的东西,但这仍然是一个开放的研究路径,它在某些方面明显不同

如标题所述,这里的问题是窗口顶部的关闭按钮(x 按钮)在 IE-8 中没有任何作用。很少,它会删除窗口的内容,但我们无法重现。关闭 (x) 按钮在那里,但它没有突出显示,也没有单击。发生这种情况时,刷新和最大化按钮也会变得无响应。

4

1 回答 1

0

将函数的第一行更改为:

var serverDetailsWindow = $("<div></div>");

...使它工作。我们之前使用 append 来创建一个新的 div。

于 2014-10-20T16:17:16.227 回答