This is baffling me and I'm afraid I might be doing something very silly.
I have a form that does an ajax call, and on success, reloads the (same) page and jumps to the submitted data toward the bottom of the page using a URL hash/fragments.
window.location.href = "/this/url/#post-10";
window.location.reload();
...
<div id="post-10">...</div>
I notice that at least with Chrome, the previous scroll position is being favored over the anchor link I am providing - so the page reloads, succesfully jumps to my id
anchor, but once the page is finished loading, it jumps up to where the scroll was on the previous page.
Is this standard behaviour? Is the best approach to fixing this to simply force the pages position using onLoad
or something similar?