The handler fires prior to the dialog being closed, but you cannot stop the dialog from being closed unless you use explicit code (calling hideDialog or showDialog with a setTimeout() perhaps).
o.wwModalDialog.dialogHandler
<script> function MessageBox(Message,Title) { // *** Create here inline or make this ref global var Mbox = wwModalDialog.createDialog("Mbox",500,"Done","Cancel",MBox_Callback); Mbox.showDialog(Message.htmlEncode(),Title.htmlEncode()); } function MBox_Callback(Result) { if (Result == 1) alert("Ok"); else alert("Cancel"); } </script>