Window.return is not returning a value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am using a window.showmodaldialog to open a page and passing a string on
window close.When I am trying to capture the returned value using the
window.returnvalue I am getting an empty string.
My code is as in opened window is
window.returnValue = "yes"
window.Close
and the code in parent window is
strResponse = window.showModalDialog(strFile,"resizable=yes, height=500,
width=500, scrollbars=yes")
msgbox strResponse
Thanks
 
Here is the code snippet from the MSDN CD (V6)
1) For your MODAL window

<HTML>
<HEAD><TITLE>Search For</TITLE>
<SCRIPT LANGUAGE="JScript">
function doOK() {
window.returnValue = window.document.all.MySearch.value;
window.close();
}
function doCancel() {
window.returnValue = "";
window.close();
}
</SCRIPT>
</HEAD>
<BODY>
<P><B>Search For:</B> <INPUT ID=MySearch TYPE=text>
<CENTER>
<BUTTON onclick="doOK()">OK</BUTTON>&nbsp;
<BUTTON onclick="doCancel()">Cancel</BUTTON>
</CENTER>
</BODY>
</HTML>
You call the above window from your calling window withfunction doSearch() {
var str = showModalDialog("search.htm");
if (str == "")
return; // user canceled search
else {
// search for the string
}
}
I am not sure but it was unclear in your post whether you were assigning the
window.returnValue from within the windowclose event and then calling
window.close()ie. User clicks 'close' button which fires the windowclose
event.Your code in the windowclose event assigns a value for
window.returnValue thenfires the windowclose event again!
 
Back
Top