There is a page with a list of goods, the transition through the pages is implemented by Ajax, if we click on the product, it opens in the same tab. And then, when we press the button back to return to the list of products, we get to the first page. How can we realize that we get to the same page with which we left? For example, dolistali to 5, opened the product and returned as well on the fifth? enter image description here

  • where is the current page number stored somewhere? if so, then just when you click back make the transition in the same way ajax itself and pass the parameter (the number of the current page). if it does not work out that way, then explain to everyone exactly how ajax works for you to navigate through the pages so that everyone can understand and suggest something - Ivan Turcan
  • The transition works like this: we send an Ajax request by reference, which is contained in the page number, and from there we insert the part with the goods instead of the current part with the goods. - Nikolay
  • remember the page number (for example, in the js variable), and when going back from the product page to the product list, then open ajax as you would when going to the next page, but the page number will already be your saved variable - Ivan Turcan
  • No, I don’t need an Ajax on the product page, can I somehow do an anchor? - Nikolay
  • one
    Dig in the direction of window.history from html 5 . You need to use history.pushState when clicking on navigation buttons. - user200141

1 answer 1

On the event "click" pagination hung history.pushState(null, null, href); where href is the link on which the AJAX request goes.

  • one
    Just note that in old browsers you still have to put up with the fact that it will return to the first page. If the project is serious, then as an option I can offer you for old browsers to make a mechanism for navigating through pages without ajax . And it seems to be good for SEO , although I'm not sure here. - user200141
  • Thank! So do it! - Nikolay