Capturing the Back button event in the Ask Question

The back button event is not recorded window.onbeforeunloador processed by the handler onbeforeunload.

There are several questions that SO asks to grab the back button without a good answer, but still, if the user clicks the back button in the browser when composing a new question on SO, the message box asking him is sure Does he that he wants to continue popping up.

This message box is different from Chrome and FF and looks like native.

So what's behind the curtains?

How can I open a browser window that allows the user to stay on the current page (for example, with onbeforeunload)?

+5
source share
1 answer

The back button event is not recorded window.onbeforeunloador processed by the handler onbeforeunload.

Not true. Check out this test case with a simple JavaScript button - back starts onbeforeunloadjust fine. Tested with the latest versions of all major browsers: Chrome 18, Firefox 11 and IE9. (Copy the link address, first go to another site, then to the violin and click the "Back" button).

So, I'm afraid that your question is not very relevant - you see native browser dialog.

+2
source

All Articles