/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script language="javascript"> //remember the scroll position for the div function setScrollValue() { var divObj = $get('<%= divcontent.ClientID %>'); var objHid = $get('<%= HiddenField1.ClientID %>'); if (objHid) objHid.value = divObj.scrollTop; } function pageLoad() { var divObj = $get('<%= divcontent.ClientID %>'); var objHid = $get('<%= HiddenField1.ClientID %>'); if (divObj) divObj.scrollTop = objHid.value; } </script> <asp:HiddenField ID="HiddenField1" runat="server" /> <div style="height:150px;overflow:scroll" id="divcontent" runat="server" onscroll="javascript:setScrollValue();"></div>