【问题标题】:why is my window.dialogArguments undefined为什么我的 window.dialogArguments 未定义
【发布时间】:2012-10-24 06:09:19
【问题描述】:

我需要在模式对话框中打开一个 .aspx 页面。这是我用来打开对话框的 JS 代码:

        if (url) {
            var fullPath = url + "/Validation.aspx";
        }
        else {
            alert("Could not find the location of the merge dialog.  Please contact your System admin and have them update the configuration entity.");
            return;
        }

        var features = "unadorned:yes;scroll:yes;resizable:yes;status:yes;dialogHeight:480px;dialogWidth:480px;";

        var args = {
            selected: selectedIds,
            page: pageIds,
            fetchXml: xml,
            entity: "xyz"
        };

        window.showModalDialog(fullPath, args, features);

在我的validation.aspx 页面中,我需要能够获取JS 参数,将它们分配给隐藏字段,然后重新发布,这样我就可以在服务器端使用这些参数值。

这是我的 .aspx 页面中的 JS 代码:

window.onload = function(){        
    if (!window.dialogArguments)
        return;

        var args = window.dialogArguments;
        ...
}

我在网络上看到了大量这样的例子。 但是...我的 window.dialogArguments 在我的 .aspx 页面中始终未定义。是什么赋予了?有人有什么想法或解决方案吗?

【问题讨论】:

  • ps:这是我的 .aspx 页面中的 JS 代码:
  • 当您尝试运行该代码时究竟会发生什么?代码sn-p在哪里,在文档头部,底部……?
  • aspx页面中的JS在header中。 window.dialogArguments 是未定义的,所以它只是从 window.onload 函数中返回。

标签: javascript asp.net modal-dialog


【解决方案1】:

我的假设是 ASPX 对话框页面是跨域打开的。

这意味着您的父页面位于一个域中,即http://abc/page.html,而您的子对话页面位于另一个域中,例如:http://def/dialog.html

如果是这种情况,似乎对访问 dialogArguments 和 returnValue 有限制。例如,查看this previous answer 上的 cmets。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-01
    • 2017-04-07
    • 2018-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多