Home Ask Login Register

Developers Planet

Your answer is one click away!

forthrin February 2016

Make browser go to top of page when reloading page

I've made a simple HTML page. When I press the Reload icon in the browser (Safari Mac, Chrome Mac, Safari iOS), the page reloads, and retains the vertical position in the page.

  1. Is this the default behaviour in browsers these days? I seem to remember that browsers used to go to the top of the page before (at least some years back). When did this change?

  2. What is the best way to make the browser go to the top of the page when the page is reloaded? Simply hook into "On Document Load", and jump to an anchor at the top?


Emil S. Jørgensen February 2016

Use window.scrollTo(0,0) on document load


Something like this should do the trick:

document.onload = function(){

Post Status

Asked in February 2016
Viewed 3,034 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life