Good day. The page is updating the DIV in this way.
echo '
setInterval (function () {
$ ("# full"). load ("get.php? id = '. $ _ GET [' id '].'");
}, 5000);
';
I need to keep the scrollbar position on the #message element with this update. Used such code:
window.addEventListener ('DOMContentLoaded', function () {
var div = document.querySelector ('# message');
var scroll = localStorage.getItem ('scroll') || 0;
div.scrollTop = scroll;
div.addEventListener ('scroll', function () {
localStorage.setItem ('scroll', div.scrollTop);
})
});
But it only works when manually reloading the page.
Are there any options? Link to code