title: Why JSF backing bean function not call from JavaScript in Firefox but working fine in IE and Chrome?
body: <p>I am trying to fire an JSF backing bean function from JavaScript when the page is being unload. It is working fine in IE and chrome but not in Firefox.</p>
  
  <p>This is how the <code>onunload</code> event get trigger in XHTML:</p>
  
  <pre><code>&lt;h:body onunload="onPageUnload()"&gt;
    &lt;h:form id="theForm"&gt;
      &lt;p id="hiddenButton" style="display:none"&gt;
        &lt;h:commandLink id="hiddenCloseEvent" styleClass="button" action="#{theBean.doHiddenCloseEvent}"&gt;
          &lt;f:param name="action" value="CLOSE"/&gt;
        &lt;/h:commandLink&gt;
      &lt;/p&gt;
    ...
    &lt;/form&gt;
  &lt;/h:body&gt;
  </code></pre>
  
  <p>When the unload event is receive, the follow JavaScript will be execute. There are 2 versions, one is for IE, and the other one is for Google Chrome.</p>
  
  <p>IE version:</p>
  
  <pre><code>function onPageUnload() {
    if( detailPage == "false" ) {
      document.getElementById('theForm:hiddenCloseEvent').click();
    }
  }
  </code></pre>
  
  <p>Google Chrome version:</p>
  
  <pre><code>window.onbeforeunload = function(e) {
    onPageUnload();
  };
  </code></pre>
  
  <p>When the <code>onPageUnload()</code> is execute, it trigger the hidden input button JSF component click event, and then fire the JSF backing bean, <code>theBean</code>, function <code>theBean.doHiddenCloseEvent</code> to do some processing. Now the situation is the JSF function is get executed in IE and Google Chrome version but not being trigger in Firefox, may I know how this problem could be solve?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I have modified the code like below:</p>
  
  <pre><code>function onPageUnload() {
    if( detailPage == "false" ) {
      alert('before');
      document.getElementById('theForm:hiddenCloseEvent').click();
      alert('after');
    }
  }
  </code></pre>
  
  <p>From the code above I found out that the <code>before</code> get prompt but the <code>after</code> doesn't prompt. This test case is verify whether the component isn't visible in the web browser.</p>