Thursday, December 17, 2009

Notifying user before leaving without saving

<script language="JavaScript">

  var needToConfirm = true;


  window.onbeforeunload = confirmExit;

  function confirmExit()


    if (needToConfirm)

      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?";



No comments: