views:

32

answers:

3

hey there,

i want to implement a little feautre with jquery, where i want to catch the event that occures when the user clicks on the "Back" button of his browser, to get to the last page.

but how?

didn't find any working solutions :-(

+1  A: 

You can't, at least not very well.

Things like onbeforeunload can fire when the user leaves a page, but the only things you can differentiate between are "Things in the page that you have put an event handler on to flag as fired" and "Other stuff".

The back button would fall into "Other stuff" along with everything from "Typing a new URL", and "Using a bookmark" to "Closing a tab".

David Dorward
+1  A: 

Get some inspiration from some Broswer-History Plugin, e.g. jQuery History Plugin. They handle the Back-Button in broswers.

The MYYN
+1  A: 

There is no direct event handler, but you can check the following thread, it might help you. http://stackoverflow.com/questions/136937/is-there-a-way-to-catch-the-back-button-event-in-javascript

Elangovan