I am developing a web application in java EE with rich interfaces. There is a link that displays the user. When a user navigates from a page or disables the browser, I must log out, because I must know when he left our page. Here is a snippet:
function fireEvent(obj,evt){ var fireOnThis = obj; if( document.createEvent ) { var evObj = document.createEvent('MouseEvents'); evObj.initEvent( evt, true, false ); fireOnThis.dispatchEvent(evObj); } else if( document.createEventObject ) { fireOnThis.fireEvent('on'+evt); } } var popit = true; window.onbeforeunload = function() { if(popit == true) { fireEvent(document.getElementById("logout_form:logout_link"),'click'); } }
This only works when closing the browser, and not in navigation or updating. I changed fireEvent (...) to return. "Everything works fine. If I type return" "after fireEvent (...), it works fine, I just donβt want to show a dialog box. How can I solve this problem?
source share