I tried the following code:

```
window.onbeforeunload = function() { return "Your work will be lost."; };

```

But even I click on a button of my page, I get an alert message.
I want to detect just the back button event. How can I do that?