I know there are a lot of questions regarding this but nothing is answering me right. I want to show a confirmation dialog when user leaves the page. If the user press Cance
window.onbeforeunload = function() { if (data_needs_saving()) { return "Do you really want to leave our brilliant application?"; } else { return; } };