问题
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
回答1:
Parent Page:
<script>
function test(str) {
alert(str);
}
</script>
Child Page:
<input id="Button1" type="button" value="Ready For Test" onclick="opener.test('my value here')" />
来源:https://stackoverflow.com/questions/3587892/asp-net-cross-domain-modal-window-window-showmodaldialog-parameter-value-alw