I need to trigger a page reload, via JS, preserving the vertical scroll position.
I'm using the solution described in another SO question:
- Calculate the current scroll position
- Add the current position as a querystring argument, then redirect
- When the page reloads, read the value from the querystring & adjust the scroll pos
However, I only want to restore the scroll position on that FIRST redirect. If the user scrolls around the page and then triggers a manual reload using Ctrl-R, I do NOT want to re-scroll to that saved position.
Is there some way of passing a single-use, visible-to-the-next-request-only value using ONLY JavaScript? Or from removing a value from document.location.href
without redirecting?
Should I be using the HTML 5 History API to "clear" the position value after I've consumed it?