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

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -