2

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 :-(

Andre
  • 9,000
  • 5
  • 26
  • 32

3 Answers3

2

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

miku
  • 181,842
  • 47
  • 306
  • 310
1

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".

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

There is no direct event handler, but you can check the following thread, it might help you. Is there a way to catch the back button event in javascript?

Community
  • 1
  • 1
Elangovan
  • 1,449
  • 2
  • 23
  • 41