Get Browser Tab Close event in JSF

3k Views Asked by At

I want to get browser tab close event in my JSF page. How can I do this using <a4j:ajax event="?" .../> is there any event is JSF ??

1

There are 1 best solutions below

0
On BEST ANSWER

Well you cannot directly get browser-tab-close event in <a4j:ajax event="?" .../> but there is work around for this

Step1: Get tab-close event from javascript like

<h:body onunload="tabClosed();">

Step2: Make JS function and call backing bean like be

<h:form>
   <a4j:jsFunction name="tabClosed" action="#{myBean.tabIsClosed()}" ></a4j:jsFunction>
</h:form>