记录DIV中滚动位置刷新页面位置保持不变

时间:2021-11-26 19:54:21

一、js部分:

<script type="text/javascript">
        $(document).ready(function () {
            $("#scroll").scroll(function () {
                Form1.divScrollValue.value = $("#scroll").scrollTop();
            });
        });
        function ScrollToSelectNode() {
            document.getElementById("scroll").scrollTop = "<%=ScrollValue%>";
        }

</script>

二、HTML部分

<body onload="ScrollToSelectNode()">

<input runat="server" id="divScrollValue" type="hidden" value="" />

<div class="air_1_2_1_2">
            <div class="air_1_2_1_2_1">摄像相列表</div>
            <div class="air_1_2_1_2_2" id="scroll">
                <TABLE id="CameraTable" cellSpacing="0" cellPadding="0" width="100%" border="0" runat="server"></TABLE>
            </div>
      
       </div>

</body>

三、C#后台:

public static string ScrollValue = string.Empty;//滚动条位置

protected void Page_Load(object sender, EventArgs e)
        {
            ScrollValue = divScrollValue.Value;

}