Listener for closing web browser

Hi,

I want to warn the user if he/she closes the web-browser window.

So is this possible to have some kind of listener to warn the user when he/she clicks on close browser ?

Note : I am using Vaadin 7.

Thanks,
Rakesh.

You could add something like this in your UI, but I don’t know if it’s supported by all browsers.

JavaScript.eval("window.onbeforeunload = function() { alert('window.onbeforeunload'); };");