Same page position with CSS?
- Started
- Last post
- 5 Responses
- Raybandana
Hi There,
I have a page that uses an infinite scroll. My problem is once I leave the page and then return back to the page with the Infinite scroll, the page scrolls to the very top of the page. I'd rather return to the same part of the page I was on. How would I do this with CSS? HTML?
Thanks a million.
- Nairn0
The trick here is that your 'infinitely-scrolled page' doesn't really exist until it's generated by whatever script you're using, so the browser doesn't have anywhere to link 'to' when its controls are used. In an ideal world the generated version of your page would've been cached so that browser navigation would return to where it came from, but I don't thin kthat's guaranteed.
So, either you have some hard-coded HTML anchors in your no longer quite 'infinite scroll' page, or you create anchors using Javascript which can then be passed as a variable back to another script which can generate the scroll from that point.
Ideally you'd have a one-stop shop infinite scroll script that does all of this for you in one package.
- On the other hand, I've not really had my head in this space properly for a while, so perhaps I'm just talking utter shit.Nairn
- This looks like it does what yo uwant:
https://infinite-scr… - see 'features', 'back-button friendly'Nairn - haha no that sounds about right... its seems once you go back, it has to load all over again.Raybandana
- close :)sted
- lol meanwhile Nairn posted a proper link :Dsted
- sted1
https://developer.mozilla.org/en…
replaceState does the trick and yes you need those anchors at least per page, and you will find online tutorials how to do this. for proper help i need an url- I found this too but wasnt to clear how to add it to my site.Raybandana
- Raybandana0
This is the page I'm having problem with
- When you go scroll down, then go to a tenders profile, then return back to all the tenders, you start at the top again. Just want to return to the same spot.Raybandana
- I returned to back to where I was before in Chrome on Mac, does exactly what you want this end.fadein11
- Yea in chrome on mobile it works. But desktop not so much.Raybandana
- Did you see the link I posted above, Ray? You should be able to swap that in for the Infinite Scroll code you use at the moment.Nairn
- I was on desktopfadein11
- ah thanks Nairn, looks good!Raybandana
- fadein11 - strange!Raybandana
- Raybandana0
I'm still having troubles getting anything to work. There must be a simple solution.
- monNom0
^ open profile page in a modal iframe?