Hello.

I am looking for ways to "make friends" ajax-download content and the button "Back" in the browser. Ie, for example, when I scroll, I’m loading a list of products with ajax, and how to make it so that when I click on any product I can get to the page of the list of products I’ve come from, but so that I did not load (scroll) the goods again? For example, as is done on ozone , goods are dynamically loaded, and when you click on a product from it, you can return to the previous page of the list of products.

Thank you in advance!

  • I don’t see that the ajax list is loaded on ozone (rather, on the contrary, I see that the url changes, the page loads entirely). But in general, this feature is in html5 - called the History API, there are also libraries that allow you to use history api with a fallback to hash addressing. - zb '

1 answer 1

The options are full, for example, you can store certain parameters (product list, product list page, height of the scroll) in localStorage . Those. when you create a page with a list of products, you will have something like this "pseudocode":

 var defaultPage = 0; var lastVisitPage = localStorage.userCardPage; if (!lastVisitPage) { localStorage.userCardPage = defaultPage; lastVisitPage = defaultPage; } console.log(lastVisitPage); 

Perhaps this question / answer will help you:

Save JS script action after reloading page