'How would you add a dialog that alerts user of which page he is staying on after pressing Cancel? - JavaScript
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?";
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
