0 Replies Latest reply on Jan 25, 2010 1:05 PM by johnzli

    Confirmation upon browser window close event

    johnzli Level 1

      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