javascript - Cant get HTML chat autoscroll to work -


i have simple html & js chat, , tryed alot of solutions how make auto scroll down when new message recived. nothing works me dont know why.. html divs:

<div id="chat-text" style="width:500px;height:100px;overflow-y:scroll">     <div><strong>welcome game</strong></div>     <div>server: type messages here.</div> </div>  <form id="chat-form">     <input id="chat-input" type="text" autocomplete="off"        style="width:500px"></input> </form> 

my javascript function

socket.on('addtochat',function(data){    chattext.innerhtml += '<div>' + data + '</div>'; });  chatform.onsubmit = function(e){         e.preventdefault();         if(chatinput.value[0] == '/'){             if(chatinput.value == '/getbigger'){socket.emit('biggercheat');}             if(chatinput.value == '/getfaster'){socket.emit('fastercheat');}         }         else {             if(chatinput.value != ''){                 socket.emit('sendmsgtoserver',chatinput.value,nickname);             }         }         chatinput.value = ''; } 

what should when new message recived / sent scroll down, ( want scroll if want read older messages , scroll down when new message recived)

thanks


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -