Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable brower's auto scroll after a page refresh?

Is there a way to disable the behavior where some modern browsers (Chrome and Safari) remember your scroll position on a page refresh?

like image 669
Anthony Avatar asked Sep 04 '13 15:09

Anthony


1 Answers

For browsers that support history.scrollRestoration, the auto scroll behavior can be turned off:

if ('scrollRestoration' in history) {
  history.scrollRestoration = 'manual';
}

source: https://developers.google.com/web/updates/2015/09/history-api-scroll-restoration

like image 84
Cory Duncan Avatar answered Oct 02 '22 15:10

Cory Duncan