2 Replies Latest reply on May 24, 2011 4:14 PM by TheorR

    on close

    TheorR

      I have the following in my web application to perform some shutdown database stuff when the user closes the browser window:

      window.onunload = cleanExit;

       

      However, this doesn't seem to work in my application inside of Adobe AIR.  Is there a way to detect that the window is closeing (in html/ajax)?

       

      Thanks.

      Theo

        • 1. Re: on close
          Peter Blazejewicz

          Hi Theo,

           

          is that html-based or Flash platform based application? Also I'm not exactly sure about "user closing window":

          - if you have embedded browser then it can be closed only via action taken on some component (embedded browser has no UI available for end user) which you've control. So when user want to close browser call function in your javascript via {HOST}.window bridge to clean up things. The same applies I think if you are closing entire air native window. If browser exists call cleanup routine via bridge and then destroy and cleanup and exit.

          - if you have html based application then you could add closing listener via:

          window.nativeWindow.addEventListener(air.NativeWindow.CLOSING, handleWindowClosing);

          and implement similar solution.

          I have no idea how Adobe WebKit version handles "unload"/"beforeunload" events - so it could be better to go routine via containing component I think.

           

          regards,

          Peter

          • 2. Re: on close
            TheorR Level 1

            Thanks,

             

            I'll give this a try tommorrow.