admin管理员组文章数量:1405170
I need to close the modal dialog with return a value in a same function
I cannot write code as follow,because when a returning a value, next line never be excuted,
function butOK_OnClick() {
return "OK";
window.close();
}
so is this the right way ?
function butOK_OnClick() {
window.returnvalue = "OK";
window.close();
}
or what is the best way to do this ?
I need to close the modal dialog with return a value in a same function
I cannot write code as follow,because when a returning a value, next line never be excuted,
function butOK_OnClick() {
return "OK";
window.close();
}
so is this the right way ?
function butOK_OnClick() {
window.returnvalue = "OK";
window.close();
}
or what is the best way to do this ?
Share Improve this question edited Jan 17, 2013 at 14:20 Madura Harshana asked Jan 17, 2013 at 14:15 Madura HarshanaMadura Harshana 1,2998 gold badges25 silver badges40 bronze badges 5- PopUp? You using a modal dialog? – epascarello Commented Jan 17, 2013 at 14:16
- Are you just trying to run a function when the popup closes? – romo Commented Jan 17, 2013 at 14:18
- thats my mistake. yes, thats the modal dialog – Madura Harshana Commented Jan 17, 2013 at 14:19
- I need to return a value when closing a modal dialog – Madura Harshana Commented Jan 17, 2013 at 14:19
-
If you want to return a value calculated in the other window to the main window (from which the popup opened), do
window.opener.[...] = [...]
before closing – marekful Commented Jan 17, 2013 at 14:20
2 Answers
Reset to default 2Assuming you're using window.showModalDialog
to open the window (since window.open
does not allow for return values), you'd just set the returnValue
property of the modal and then set it to a variable in the opener.
Opener window:
var returnedValue = window.showModalDialog(url);
Modal window:
window.returnValue = 'foo';
window.close();
you can use,
$("#modalId", window.top.document).data("cancelled", true);
$("#modalId", window.top.document).data("returnValue", returnVal);
本文标签: Close modal dialog with returning a value in javascriptStack Overflow
版权声明:本文标题:Close modal dialog with returning a value in javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744289609a2599051.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论