I added some page transitions to my site. Now whenever someone clicks on the browser back button, that redirects him to his previous site, his scroll position on that page gets restored automatically. If the user has scrolled down on the previous page, this behavior leads to an ugly page jump in the current window less than a second before it fades out.
1) Am I able to delay this default browser behavior?
2) If 1 is not possible, am I able to disable the default behavior and store & restore scroll positions manually instead?
I added some page transitions to my site. Now whenever someone clicks on the browser back button, that redirects him to his previous site, his scroll position on that page gets restored automatically. If the user has scrolled down on the previous page, this behavior leads to an ugly page jump in the current window less than a second before it fades out.
1) Am I able to delay this default browser behavior?
2) If 1 is not possible, am I able to disable the default behavior and store & restore scroll positions manually instead?
Share Improve this question asked Jan 17, 2018 at 19:14 heroxavheroxav 1,4671 gold badge25 silver badges67 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 23 +50Although it is experimental, you can try adjusting the History scrollRestoration from "auto"
to "manual"
.
There are a few polyfills out there to help with cross-browser compatability too.
if ('scrollRestoration' in history) {
// Back off, browser, I got this...
history.scrollRestoration = 'manual';
}
it is default browser behaver - isn't it what you looking for ?
– Armen Commented Jan 20, 2018 at 7:38