0

The scroll bar doesn't go down on the Chat Page, so what I need to do is I want it to go away when people send messages between themselves but the scrollbar doesn't scroll down when the other person sends the message.

<div class="messages" id="messages" style="overflow:auto">
  <div class="message" id="message">Yükleniyor...</div>
</div>
chat.fetchMessages = function() {
  $.ajax({
    url: 'chat.asp',
    type: 'post',
    data: {
      method: 'fetch'
    },
    success: function(data) {
      $('#messages').html(data);
      $("#messages")[0].scrollHeight - $("#messages").scrollTop() == $("#messages").outerHeight()
    }
  });
}
.messages {
  border: 1px solid #red;
  height: 450px;
  overflow-y: auto;
}
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Musti
  • 1
  • 1 - The line you're supposed to be scrolling is a compare statement (maybe you meant "=" instead of "=="). 2 - You access scrollHeight of "message" with with array 0 and then scrollHeight, you should do the same for outerHeight. I don't know if this fixes your problem, but if you're using scrollTop function, can't you do what you intend only with that function? – H. Figueiredo Feb 25 '19 at 10:01
  • Oh I just noticed outerHeight is a method as well, sorry my bad, nevermind point 2. – H. Figueiredo Feb 25 '19 at 10:02
  • Not sure what last line of your code suppose to do, but here some example https://stackoverflow.com/questions/11715646/scroll-automatically-to-the-bottom-of-the-page – maximelian1986 Feb 25 '19 at 10:38

0 Answers0