I'm trying to simulate onclick event in a h:commandButton when I close my browser.
Here is my code:
<body onBeforeUnload='closingBrowser()'>
function closingBrowser() {
document.getElementById('main:commandButtonHidden').onclick();
return false;
}
This javascript function call the function associated with my button which has this definition:
<h:commandButton id="commandButtonHidden"
value="checkPasswords().Login"
onclick="javascript:checkPasswords();" actionListener="#{init.closingBrowser}" />
and checkPasswords():
function checkPasswords() {
alert("checkPasswords");
return true;
}
This function has nothing interesting because what I want is the function in my actionListener.
This works perfect in IE and FF, but not in chrome or Opera.
The alert always is fired in all browsers, but the actionListener NO, just in IE and FF, and it has no sense.
Somebody knows anything about this.
Thanks