javascript - Scroll a HTML div if height changes -
javascript - Scroll a HTML div if height changes -
using javascript how can scroll html div if height of div changes?
in below code if mychat's
height changes need chat
div's scroll bar should come down. javascript wrong can right please.
my code is
<style type="text/css"> #chat { height:250px; width:200px; overflow:auto; background-color:aqua; padding:5px; } </style> <script type="text/javascript"> function show() { var mydiv = document.getelementbyid('mychat'); var mydiv2 = document.getelementbyid('chat'); var sval; if(mydiv.clientheight != sval) { mydiv2.scrolltop = mydiv2.scrollheight; } sval = mydiv.clientheight; } </script> <asp:scriptmanager id="scriptmanager1" runat="server" enablepartialrendering="true"> </asp:scriptmanager> <div id="chat"> <asp:timer id="timer1" runat="server" interval="200" ontick="timer1_tick"> </asp:timer> <asp:updatepanel id="updatepanel1" runat="server" updatemode="conditional"> <contenttemplate> <div id="mychat" runat="server"> </div> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="timer1" eventname="tick" /> </triggers> </asp:updatepanel> </div>
i sorry don't have plenty knowledge in coding javascript.
this fiddle seems want - if not, @ to the lowest degree steers in right direction.
http://jsfiddle.net/7uvzd/7/
adapted code i've used how scroll row of table view (element.scrollintoview) using jquery?
javascript html
Comments
Post a Comment