0

I have a DIV with scroll that have a information from the mySQL.

this DIV supose to be a chat (like the facebook chat) and its refresh with ajax every some seconds.

i need that this DIV alwase will show me the information that in the bottom (like the facebook chat)

how i made it (keep the scroll down)?

<div style='width:100%; height:275px; bottom:25px; overflow-y:scroll;' id='aaa'>
  chat 
</div>
Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57
ldoroni
  • 107
  • 2
  • 9

2 Answers2

2

Try the following

var objDiv = document.getElementById("your_div");
objDiv.scrollTop = objDiv.scrollHeight;
Ahsan Shah
  • 3,931
  • 1
  • 34
  • 48
0

In your div tag set style as

style='width:100%; height:275px; bottom:25px; overflow-y:auto;'

when the new chat message appears the scroll bar of y-axis has been automatically drops

Naveen Kumar Alone
  • 7,536
  • 5
  • 36
  • 57