Upon searching StackOverflow for restoring scrollbar position using JavaScript, I came across this suggestion from https://stackoverflow.com/a/3812235/1101391
document.getElementById("invoice_incomplete").scrollTop = 200px;
If I’m not mistaken, this code is somewhat related to what I really want to achieve. How can you actually save/remember/restore the position of the scrollbar on a <textarea> after reloading the page, and not just set your preferred scrollbar position?
Like when you type some paragraphs on the <textarea> and you reload the page, the scrollbar should be on its same position before reloading the page.
Edit:
Ended up using the onunload event, and an invisible <input> tag, as per mr. @ruakh’s suggestion.
You can save the value in an invisible text-field that serves no other purpose:
you can use a
window.onunloadevent (hat-tip to katspaugh’s comment) to setand a
window.onloadevent to set(The above assumes that
textareais a variable referring to the textarea).When the browser reloads the page, if it restores the form contents, then it will restore the contents of the invisible text-field together with the contents of the textarea.