I am creating chat program in php using jquery, ajax and MySQL.
and my problem how to auto scroll down when div is overflowed.
like when user enter new line it will goes down and I want to auto scroll down when new messages appeares down.
and I am trying to do this dynamically using scroll height change to trigger this$('.main').stop().animate({scrollTop:$('.main')[0].scrollHeight}, 1000);
. because using scroll height chaning it will also scroll to ather users browser who is chating on the other side.
I also have tried to trigger scroll down event using keypress
and click
event but that is only works for the current users browser, so on the other hand for another user that wont work or wont auto scroll down, he have to scroll manually to view new messages and I dont want that.
so thats why I am trying to use scroll height event. I also tried the mutate plugin for this purpose and it works fine only for the localhost and conflict on the live server and super slow down the chat.
So I have to leave this plugin for this problem.
so please kindly give me the solution without using any plugin to acheive this purpose.
many thanks in advance.