Prompt user for Navigating away or attempt to close the browser

There might be requirements to provide users some information while navigate away from their page. Javascript has a method called onbeforeunload can be used to give some feedback while users navigate away or close the browser

    <script type="text/javascript">
    <!--
    var _isPostBack = false;
    window.onbeforeunload = function ()
    {
     if( _isPostBack == true )
      return; // Let the page unload

     if ( window.event )
      window.event.returnValue = 'You will lose any unsaved changes!'; // IE
     else
      return 'You will lose any unsaved changes!'; // FX
    }
    // -->
    </script>

Try to nvaigate away and you will be prompted!

window_on_before_unload

1 Responses to "Prompt user for Navigating away or attempt to close the browser"

  1. can u gave me a tutorial on this?? i need it please... it great

Leave a Reply