Hello, I have a question: I do chat and iframe 'om output its contents, everything would be fine, but when there are many messages, scrolls appear and do not go down, so I ask for help.

How can you realize that when a new message appears, scrolling goes down, or after a certain time? Only one thing: without refreshing the page. Messages are output via AJAX and if updated, they are lost.

Thanks for the help and time for me :)

  • one
    @Manitikyl, do you save messages somewhere (DB, text file, etc.)? - Deonis
  • no) they are outputted via COMET to customers :) - Manitikyl


2 answers 2

@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 .

     function scrollMessage(msgBox){ window.scrollBy(0, $(msgBox).height()); } 

    msgBox is an element with a message displayed on the screen.