ASP.NET cross domain modal window (window.showModalDialog) - parameter value always “undefined”

我的梦境 提交于 2019-12-11 07:43:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!