For instance, I open a web page, and scroll down to some position,
then I refresh the chrome browser, the browser could scroll the previous position again
How can I use javascript or css to let the browser to forget the scroll?
I have try $(window).scrollTop(0)
, but it doesn't work
It is resolved in the question below.
Disable brower's auto scroll after a page refresh?
Here is a clean way of getting this done.
By simply setting the body display to 'none' you don't have to worry about a flash of the browser scrolling to the top of the page before it is unloaded and the scroll position will automatically be reset to 0.
A simple way that I can say is to run this code on page load:
OR
It set the browser viewport to the top of the page, again.