ASP.NET 跨域模态窗口 (window.showModalDialog) - 参数值始终为“未定义”
我有两个网页,父页面 .aspx 和子页面 .html。 在父页面上,我有 JavaScript 函数,用于通过 window.showModalDialog 调用子页面作为模式窗口。
function viewCourseModal(url) {
var sPars = SomeParameters();
var returnedValue = window.showModalDialog(url, "", sPars);
document.getElementById("modalReadyForTest").value = returnedValue;
return returnedValue;
:
在子页面上我有以下内容
<script LANGUAGE="JavaScript">
function closewindow() {
window.returnValue = "someValue";
window.close();
}
<input id="Button1" type="button" value="Ready For Test" onclick="closewindow()" />
因此,当我启动父窗口并调用子模态窗口时,单击按钮 Button1 后,带有“someValue”的参数将返回到父窗口(到 modalReadyForTest 控件)。
当我在同一域中拥有父页面和子页面时,它工作得很好。当我将它们放在不同的域上时,参数的值不会被传递,而是始终“未定义”。
有没有办法让来自不同域的模态窗口将参数值返回到父页面?这些跨域问题是否可以完全解决,或者我应该尝试完全不同的方法?
我将非常感谢任何帮助。
谢谢,安瓦尔
I have two webpages, parent page .aspx and child page .html.
On parent page I have JavaScript function for invoking child page as modal window via window.showModalDialog.
function viewCourseModal(url) {
var sPars = SomeParameters();
var returnedValue = window.showModalDialog(url, "", sPars);
document.getElementById("modalReadyForTest").value = returnedValue;
return returnedValue;
}
On the child page I have the following:
<script LANGUAGE="JavaScript">
function closewindow() {
window.returnValue = "someValue";
window.close();
}
<input id="Button1" type="button" value="Ready For Test" onclick="closewindow()" />
So when I launch parent window and invoke child modal window, parameter with "someValue" gets returned to the parent window (to modalReadyForTest control) upon clicking the button Button1.
It works fine when I have both parent and child pages on the same domain. When I have them on different domains, value of the parameters does not get passed and instead it is always "undefined".
Is there any way to have modal window from different domain returning parameter value to parent page? Can those cross domain issues be solved at all or should I try completely different approach?
I would highly appreciate any assistance.
Thanks, Anvar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
父页面:
子页面:
Parent Page:
Child Page: