7 Replies Latest reply: Jan 26, 2010 6:40 AM by johnzli RSS

    Confirmation upon browser window close event

    johnzli Community Member

      Our web application open a popup browser window contains a cutomized LiveCycle workspace from where the user submit a data form. I want to implement a feature that when the user close the browser window, a message box will pop up for user's confirmaiton (OK to close the window, Cancel to remain in the workspace window). Here is my code:

       

      In javascript:

       

          <script LANGUAGE="JavaScript">

       

              window.onbeforeunload = confirmExit;
             
              var needToConfirm = true;
             
              var confirmMsg = "Are you sure you want to exit this page?"
             
              function confirmExit() {
                  if (needToConfirm) {
                      alert("Event triggered!");
                      event.returnValue = confirmMsg;
                      //return confirmMsg;
                  }
              }

       

              function setNeedConfirm() {
                  needToConfirm = true;
              }
             
              function releaseNeedConfirm() {
                  needToConfirm = false;
              }

       

           </script>

       

      In *.mxml:


           flash.external.ExternalInterface.call("releaseNeedConfirm"); or flash.external.ExternalInterface.call("setNeedConfirm");

       

       

      This approach works perfectly with IE, but for some reason it does not work with FireFox. I confirmed that the line alert("Event triggered!") is reached in FF, but no confirmation box is popped up.

       

      Anyone can help me here?

       

      Thanks

       

      John