Dims
Dims

Reputation: 51159

How to catch browser close in Liferay?

I am catching user logouts with hook with

logout.events.post=...

action and this works.

But also I want to catch browser close as logout too.

How can I accomplish this?

servlet.session.destroy.events=

is not fired I guess.

Thanks.

Upvotes: 1

Views: 1469

Answers (1)

gvaish
gvaish

Reputation: 9404

The browser close happens on the client... and the session may not have been destroyed (user may not have logged out).

On the client side, you may want to do

window.onbeforeunload = function() {
     make_an_ajax_call_to_server_to_notify();
     return null;//to close
     //OR
     //return "Do you really want to close?" to let user click an "Ok" button
}

Upvotes: 3

Related Questions