Question: How do I frame the upper and lower scroll bars to be at the bottom by default? It is a chat tool with a lot of data. The up and down scroll bars that appear every time it is refreshed are at the top by default. You still need to scroll down to the bottom to see the chat history. There is Is there a way to make it appear below?
Answer: Write window.scrollTo(0,9999999) directly in the iframe or set the scrollTop of the container such as div
document.getElementById(“x”).scrollTop = document.getElementById(“x”).scrollHeight
window.scrollTo(0 ,9999999)
This is solved below, but after there is new information, the scroll bar will not automatically go to the bottom. I hope that like the QQ chat window, when there is new content, it will automatically go to the bottom. Below, how should we solve it?
Then you should determine the position of the currently generated content, that is, its top or margin-top, and then set the height of the scroll bar. This is enough. Call the scroll bar every time it is generated. The height changes. Every time you get new data, call the window.scrollTo(0,9999999) method to solve this problem!