开发者

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

开发者 https://www.devze.com 2023-01-13 17:19 出处:网络
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.

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) u开发者_如何学Cpon 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


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')" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号