Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access the history state of the previous page when a user clicks 'back'

Is there a way using JS of accessing the history state of the previous page when a user clicks the 'back' button?

like image 517
David Gard Avatar asked Nov 14 '11 12:11

David Gard


1 Answers

Unfortunately you're not allowed to read previous or next states. All you can do is reading current state, using history.state.

But if it all happens on the same page without reloads, why don't you save data on you own stack. You can use array for this - just save the same data to array and new state.

like image 53
Maciej Pyszyński Avatar answered Sep 30 '22 20:09

Maciej Pyszyński