I am creating a website where I have to large content boxes that are absolutely positioned -- one at the top of the screen and one below off screen. I have the <body> element set to overflow-x and overflow-y none.
body {
overflow-x: hidden;
overflow-y: hidden;
}
When a button is clicked on the screen, the overflow-y changes to visible. This works just fine. However, if the user is near the bottom of the screen (as in farther down compared to when the page first loaded) and they reload the page, the user stays where they are but the overflow-y gets set to none and the user is stuck halfway down the page. Is there a way to have the user always start at the top of the page?
Also, this is completely vanilla js, html, and css -- no libraries or anything like that. If I need to add any other parts of my code let me know. Thanks
I have tried to use various methods of running code on load or before load (stuff like scrollTo(0,0) and the like). Having the page scroll before the reload works but does not look very good. It would be nice if it could just load at the top without the user actually seeing it move if that makes sense.