I want to show a jquery ui dialog , if user will reload, close the browser. I tried :
$(window).bind('beforeunload', function () {
$("#confirm").dialog({ width: 500, modal: true,
buttons: {
"Ok": function () {
// let the page reload
},
"Cancel": function () {
// cancel reloading the page
$(this).dialog('close');
}
}
});
});
But the page is reloading without showing confirmation dialog. If i put a return statement then it shows a general alert message. But i want to show a dialog. How can i do this ?