You need to sign in to do that
Don't have an account?
JK84
Script to execute when the browser is closed
Hi,
Is there a way we can have a script executed or a method called in Apex when a Salesforce user closes the browser ? I tried calling the event "window.onbeforeunload" in Javascript, but this event is not supported by all browsers.
I want to capture the logout time of my SF users, but some of them directly close the browser instead of logging out, so is there a way I can have an apex called when the browser is closed and have the apex update a record in the backend ?
Thanks !!
Hi JK84,
I researched but could find only the use of these javascript events - onunload and onbeforeunload being used to capture Browser close:
Following are the links that I found which have some sample codes - might help if you go through:
-http://boards.developerforce.com/t5/Visualforce-Development/Detect-Browser-Close-events/td-p/202411
-http://stackoverflow.com/questions/3888902/javascript-detect-browser-close-tab-close-browser
-http://stackoverflow.com/questions/6622461/how-to-capture-browser-close-event-in-javascript
Thank You Sonam !! I did go through these links earlier, but the issue is that onbeforeunload event is not supported by all the browers currently and I guess even if we call some Apex method through JS to update a record in the backend onunload, pageInterrupted exceptions might occur when the browser is closed abruptly.
So, was looking for an alternate approach which could reliably update the timestamp when the browser was closed by a salesforce user !!