How do you prevent a webpage from navigating away in JavaScript? -
How do you prevent a webpage from navigating into JavaScript? Using
onunload allows you to display messages only , But it will not disrupt the navigation (because it is too late). However, you can use onbeforeunload and it will disrupt navigation:
window.onbeforeunload = function () {return "Are you sure you want to navigate Are you? "; } Edit : changed confirmation () as a statement in the form of a confirmation window due to this reason Happened, but with the confirmation confirmation the second confirmation.
Comments
Post a Comment