All the $.messager functions work in async mode. This means that the user can't block it before doing any more. To make the confirm message window works like a native confirm window in 'onBeforeClose' event, please try the code below:
$('#win').window({
onBeforeClose:function(){
var p = $(this);
$.messager.confirm('Confirm','Are you sure you want to close?',function(r){
if (r){
var opts = p.panel('options');
var onBeforeClose = opts.onBeforeClose;
opts.onBeforeClose = function(){};
p.panel('close');
opts.onBeforeClose = onBeforeClose;
}
});
return false;
}
})