I am implementing a web page with dynamic content. In particular, I have a "div" which I update its content in the following way:
This is the "div":
<div id="informationONDevices"></div>
I proceed to delete its content:
document.getElementById("informationONDevices").innerHTML = "";
Finally, I insert "divs" inside the original "div" (the code that follows is inside a loop):
var element = document.createElement("div");
element.innerHTML = "<h3>Dades de la sonda amb ID: " + this.responseXML.getElementsByTagName('addONDevices')[count1].childNodes[0].nodeValue + " i Alias: " + this.responseXML.getElementsByTagName('aliasONDevices')[count1].childNodes[0].nodeValue + "</h3>" + "<br><br>"
+ "<span class='title'>Actual</span><br>";
document.getElementById("informationONDevices").appendChild(element);
The problem is that every time I update the content of the "div" the page does autoscroll and does not stay where it was. Any solution? I've been looking for and trying a lot of things and none has helped me.
Thank you very much!