[ASP.NET] scroll-position-of-div 記憶div滑動的位置

如標題

參考來源

https://www.c-sharpcorner.com/blogs/maintain-scroll-position-of-div-on-postback-in-asp-net

 

有套用jquery 修改寫法如下

window.onload = function() {  
        var div = document.getElementById("dvScroll");  
        var div_position = document.getElementById("div_position");  
        var position = parseInt('<%=Request.Form["div_position"] %>');  
        if (isNaN(position)) {  
            position = 0;  
        }  
        $("#dvScroll").scrollTop(position);
        div.onscroll = function() {  
            div_position.value = $("#dvScroll").scrollTop();  
        };  
    };
<input type="hidden" id="div_position" name="div_position" />

 

以上文章僅用紀錄資料使用.....