最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - why is my window.dialogArguments undefined - Stack Overflow

programmeradmin5浏览0评论

I need to open up a .aspx page in a modal dialog. Here is the JS code I use to open the dialog:

        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);

In my validation.aspx page I need to be able to grab the JS arguments, assign them to hidden fields, then repost, so I can use those arg values server side.

here is my JS code in my .aspx page:

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

        var args = window.dialogArguments;
        ...
}

I have seen tons of examples of this working throughout the web. But...My window.dialogArguments is always undefined in my .aspx page. What gives? anyone have any thoughts or solutions?

I need to open up a .aspx page in a modal dialog. Here is the JS code I use to open the dialog:

        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);

In my validation.aspx page I need to be able to grab the JS arguments, assign them to hidden fields, then repost, so I can use those arg values server side.

here is my JS code in my .aspx page:

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

        var args = window.dialogArguments;
        ...
}

I have seen tons of examples of this working throughout the web. But...My window.dialogArguments is always undefined in my .aspx page. What gives? anyone have any thoughts or solutions?

Share Improve this question edited Oct 23, 2012 at 20:38 Erik Volkening asked Oct 23, 2012 at 20:31 Erik VolkeningErik Volkening 671 gold badge1 silver badge10 bronze badges 3
  • ps: here is my JS code in my .aspx page: – Erik Volkening Commented Oct 23, 2012 at 20:32
  • What exactly happens when you try to run that code? Where is the code snippet located, in the document head, the bottom...? – Pekka Commented Oct 23, 2012 at 20:42
  • the JS in the aspx page is in the header. the window.dialogArguments is undefined, so it just returns out of the window.onload function. – Erik Volkening Commented Oct 23, 2012 at 20:57
Add a ment  | 

1 Answer 1

Reset to default 3

My assumption here is that the ASPX dialog page is being opened cross-domain.

This would mean that your parent page is in one domain aka: http://abc/page.html, and that your child dialog page is in another domain like: http://def/dialog.html.

If this is the case, it seems as though there are restrictions against accessing dialogArguments and returnValue. Check out the ments on this previous answer for example.

发布评论

评论列表(0)

  1. 暂无评论