After further research, I came up with a simple solution that uses HTML5 localStorage.
Here I made a script to save the caret position:
function caretPositionSave() { window.localStorage.setItem("CaretPosition", document.querySelector("#editor").selectionStart); };
And one more to download it:
function caretPositionLoad() { document.querySelector("#editor").focus(); if (localStorage.CaretPosition) { document.querySelector("#editor").selectionStart = localStorage.CaretPosition; }; };
They, combined with similar functions to set the scroll position of the screen, look great, a trick!
source share