javascript 为什么我的 window.dialogArguments 未定义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13038764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
why is my window.dialogArguments undefined
提问by Erik Volkening
I need to open up a .aspx page in a modal dialog. Here is the JS code I use to open the dialog:
我需要在模式对话框中打开一个 .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);
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.
在我的validation.aspx 页面中,我需要能够获取JS 参数,将它们分配给隐藏字段,然后重新发布,以便我可以使用这些arg 值服务器端。
here is my JS code in my .aspx page:
这是我的 .aspx 页面中的 JS 代码:
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?
我在整个网络上看到了大量这样的例子。 但是...我的 window.dialogArguments 在我的 .aspx 页面中始终未定义。是什么赋予了?任何人有任何想法或解决方案?
回答by GotDibbs
My assumption here is that the ASPX dialog page is being opened cross-domain.
我在这里的假设是 ASPX 对话框页面是跨域打开的。
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
.
这意味着您的父页面位于一个域中,又名: http://abc/page.html
,而您的子对话框页面位于另一个域中,例如:http://def/dialog.html
。
If this is the case, it seems as though there are restrictions against accessing dialogArguments and returnValue. Check out the comments on this previous answerfor example.
如果是这种情况,似乎对访问 dialogArguments 和 returnValue 有限制。例如,查看对先前答案的评论。