Reputation: 35
Scenario : Main Page has a link to table created from https://datatables.net/
Path followed->
Intended -> Clicking Back Button should go to last seen page.
For example -
User click on page 4, then page 8, then page 7, here after clicking back button it should go to page 8
Upvotes: 0
Views: 2993
Reputation: 1280
If you are using datatable , they provide a state save flag, by using that you can save your last visited page.
Code :
$(document).ready(function() {
$('#example').DataTable( {
stateSave: true
} );
} );
Reference : https://datatables.net/examples/basic_init/state_save.html
Upvotes: 1
Reputation: 351
You should rewrite your URL with a GET parameter as http://yoururl.com/?page=3 each time that you change your table page.
Then when you come back from the browser's back button, read this parameter in order to go to your wanted page.
Edit 1: Check this to know how to manipulate your browser history: https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries
Edit 2: The first that I wrote at the beginning (You should add a GET param...) it is not necessary if you modify history entries with Javascript. But I think it could be interesting in order to copy/paste URL if you want to share table content with someone.
Upvotes: 1