var userChoice = showModalDialog("../Iframe.aspx?FormName=sample.aspx", window, "dialogTop:300px;dialogLeft:350px;dialogHeight:182px;dialogWidth:370px;help:no;scroll:no;status:no;");
alert(userChoice); /* here iam not able to get 'Y' */
if (userChoice == 'Y')
return true; else return false;
Below is the Sample aspx page:
input type="button" value="Yes" onclick="choice('Y')"
function userChoice(option)
{
window.returnValue = option;
alert(window.returnValue); /* here iam getting 'Y' */
parent.close(); // I have tried with self.close() also
}
Asked
Active
Viewed 7,228 times
3
1 Answers
2
You can't close parent.window
from modal dialog. Use window.close()
or top.close()
to close the modal.
There was a bug with returnValue
within Chrome, it seems it's not fixed yet, plese try these:
-
Thanks for your answer. I have tried with window.close() --> it is not closing in mozilla and top.close() --> it is closing in mozilla but the value is returning null after closed instead of 'Y' – chinna373 Dec 06 '12 at 08:19
-
@chinna373 There should be no problems with Firefox, for Chrome, please follow the links I've provided in my answer. – Teemu Dec 06 '12 at 08:27
-
I have tried in mozilla, its not working and googled. please check this link also "dotnetspider.com/forum/305804-How-close-showModalDialog-FireFox-Chrome.aspx" – chinna373 Dec 06 '12 at 08:33
-
@chinna373 Hmm... I can't reproduce this issue in FF 17.0.1. Can you save an example code in http://www.jsfiddle.net ? Also this may have something to do with `.aspx`, have you tried to load a regular `.html` page into your modal dialog? – Teemu Dec 06 '12 at 08:38
-
I had the same issue with closing the showModalDialog in FF. `top.close()` did work for me(IE,Chrome as well). Thanks a lot @Teemu – highfive Dec 17 '12 at 05:51