pain of browser back button

browser, javascript

Solution

If you build a one page web app (meaning a single page is loaded, then all changes are done dynamically in that page with Javascript) you have options:

When the user clicks the back button, you leave the page, since it's the only one, and you can warn the user through the event window.onbeforeunload

And then, if you need/want more control of the back/next button behaviour, you can add a hash( # ) key to handle that. See my answer to that question: Change the get parameters in the address bar in jquery

Problem

Is there any way using JavaScript(or something else) to detect/prevent that user clicked on browser back/forward button ? I would like to know about the common practice to deal with this issue. This is really pain especially in the work flow like ordering.

Original source

Related problems