@Manitikyl , it’s superficially familiar with Comet, so it’s hard to advise something. If it is interesting, here are two articles on your question - Part 1 , Part 2 . I try not to link to the site Popova, because I can't stand it organically, but this is just a translation of the original article . Fully take everything to attention, you do not really need it. Look at the part that is responsible for scrolling. Open the " Demo " in two browsers, write a message (maybe several, in order to fill the chat window) in one of them and see the result of work in the other.
PS And God forbid, that by visiting the site I specified, you took the lessons of Popov! )) Read the articles and removed the site from the history, clearing the cache and washing it with soap;)
In general, in my opinion, the most intelligent solution is WebSockets - an add-on to the HTTP protocol that supports a long-term connection. Only here bad luck ... not supported by all browsers. You can read about WebSockets here .