Posted By

lance on 08/05/10


Tagged

scroll position


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

franc23


Remember div scroll position using javascript and ASP.Net


 / Published in: JavaScript
 

  1. <script language="javascript">
  2. //remember the scroll position for the div
  3. function setScrollValue() {
  4. var divObj = $get('<%= divcontent.ClientID %>');
  5. var objHid = $get('<%= HiddenField1.ClientID %>');
  6. if (objHid) objHid.value = divObj.scrollTop;
  7. }
  8. function pageLoad() {
  9. var divObj = $get('<%= divcontent.ClientID %>');
  10. var objHid = $get('<%= HiddenField1.ClientID %>');
  11. if (divObj) divObj.scrollTop = objHid.value;
  12. }
  13. </script>
  14.  
  15. <asp:HiddenField ID="HiddenField1" runat="server" />
  16.  
  17. <div style="height:150px;overflow:scroll" id="divcontent" runat="server" onscroll="javascript:setScrollValue();"></div>

Report this snippet  

You need to login to post a comment.