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

  • Can show your HTML code - L. Vadim

1 answer 1

Solved the issue. Split update into 2 actions. At the parent, set the scrollbar and update the content of the child. The same with the second element.
The question is closed