How to stop unloading a window?

when the user clicks on another link or refreshes the page, the window is unloaded, how to prevent / confirm it?

+4
source share
3 answers

From here http://bytes.com/topic/javascript/insights/825556-using-onbeforeunload-javascript-event

<script type="text/javascript"> window.onbeforeunload = function(){ return 'Your Returned String Goes Here';} </script> 
+6
source

I think the onbeforeunload event handler will be what you are looking for.

Try the following:

  window.onbeforeunload = confirmExit; function confirmExit() { return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?"; } 
+3
source

Look at the upload at the bottom of the page .

0
source

All Articles