views:

26

answers:

1

Hi,

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  A: 

Hi, try this:

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')" />
Cesar
Well that *definitely* won't work cross-domain.
bobince
Thank you guys for your assistance. We found solution for this dilemma. Seems like JavaScript cross domain parameters passing is prevented by built-in security mechanisms. So what we did is we used iFrame to create illusion that both pages are under the same domain. Seems to be functional at this point.Thanks, Anvar
Anvar