title: onbeforeunload javascript calling backing bean method
body: <p>I am working on a website using jsf and getting benefit of the the features of primefaces, while I am managing the idea of saving changes onbeforeunload I'd face a problem. 
  I am using a javascript for onbeforeunload, in order to save changes done, before making refresh, back, or closing for browser, knowing that am using firefox browser, 
  Here's my javascript code: </p>
  
  <pre><code>Window.onbeforeunload= handleOnClose();
  Function handleOnClose(){
  If(document.getElementById("MyForm:btnEdit").disabled== true {
  If confirm("The page will close, Do you want to save changes?")
  Save();
  }
  }
  </code></pre>
  
  <p>And I am calling the save method in the javascript from a backing bean, using:</p>
  
  <pre><code>&lt;p:remoteCommand name="Save" actionListener="#{bean.save()}" /&gt;
  </code></pre>
  
  <p>The problem is that javascript is firing naturally, but the method responsible for saving is called only and only when closing browser but NOT CALLED WHEN MAKING BACK OR REFRESH !
  Is there any idea or hint for this problem ?  </p>