Can a form tell if a customer has clicked the cross on the browser window, and do something, like a background save, or a prompt or something like that?

    CommentAdd your comment...

    1 answer


      Hi Fiona,

      There is a default option in composer to alert the user when they attempt to leave the form by closing the browser window. You can find it in 'Generation Options' -> 'Policies' -> 'HTML Generation' -> 'Leave Page Warning (HTML)'.


      You can also write custom javascript that will run when the page is closed using something like:

      window.onbeforeunload = function(){
       return 'Are you sure you want to leave?'; 

      Note that there are limits to what browsers will allow you to do in the 'beforeunload' event, so it may not be possible to do a background save before leaving the form in this way.


      1. Jye Cusch

        Good answer here Chris, I'd just add that getting the window.onbeforeunload to do anything other than display a message (such as run a Dynamic Data Service) across devices and browsers is exceptionally difficult. Different browser (and even the same browser on a different device) will implement this event and other events that run when closing tabs in completely different ways. Also, with mobile devices there is a high likelihood that the person will hit their 'home' button to close the browser, rather than close the tab.

      CommentAdd your comment...