A
A
Alexey Konovalov2020-04-20 10:17:06
JavaScript
Alexey Konovalov, 2020-04-20 10:17:06

How to correctly go back when loading content ajax?

Hello! I'm trying to make an infinite ribbon, but I'm running into a problem. Let's say the user scrolled down 500 posts and decided to open it, read it and clicked the back button. What options are there to get back to the 500 post in the feed, other than opening the post with ajax, on top of the main content?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2020-04-21
@xmoonlight

Landmark: the desired "anchor" (link) in the display area and the page scroll vector relative to it, to load the tape above or below.
We write in cookies: the URL along with the anchor to the desired post in the feed, when returning with these cookies, we “collapse” everything above the desired post so as not to drive traffic and force the browser / user to scroll / scroll down and immediately delete the cookies.
But it is necessary to provide for Ajax loading and up if he wants to read the tape in the opposite direction (rising up).

V
Vladimir Druzhaev, 2020-04-22
@OtshelnikFm

VK chose the least problematic approach - opening in a modal window. They even open articles in a modal but make the overlay white and it seems like you are on a separate page. The whole thing is closed by a simple click on the "Close" button.
In a comment to the xmoonlight answer, I wrote what hemorrhagic situations will have to be solved with your idea to open it on a new page. And this is just what came to mind - there are many devices and there will be even more options for non-standard user behavior. You then fix it and maintain it. Though if testing - your path - implement. After each update, you will automatically launch them and watch all the accumulated situations that nothing has fallen off.

B
bro-dev, 2020-04-27
@xPomaHx

Usually it is enough to return not to the previous feed, but to a place in the pre-feed, so when you click on the show more button, you need to move the pagination and write page = 2 in the url, after clicking back, we return to the same place where there will be 500 pages with a default amount loaded posts, if you really want to, you can add a button on top of "load previous"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question