This function asks a user if he is sure he wants to exit a page or not. My question is... If the user pressed cancel (if he wanted to stay on the page) how would you make it so the alert says "Staying on 'page title' " ?
This is the code:
window.onbeforeunload = function(e) {
return "Do you want to exit this page?";
};