Hey friends,
Here's a snippet of code that I use to save the scroll position. I use it when a user has navigated away from a long index page and I want them to return to the same place.
Note, for an index, you must add it in the code injection for the INDEX, not the page section.
<script type="text/javascript">
function refreshPage () {
var page_y = document.getElementsByTagName("body")[0].scrollTop;
window.location.href = window.location.href.split('?')[0] + '?page_y=' + page_y;
}
window.onload = function () {
setTimeout(refreshPage, 35000);
if ( window.location.href.indexOf('page_y') != -1 ) {
var match = window.location.href.split('?')[1].split("&")[0].split("=");
document.getElementsByTagName("body")[0].scrollTop = match[1];
}
}
</script>
Let me know if this helps!