拖动滚动设置以滚动,以便用户可以滚动,但是当刷新发生时,滚动会返回到顶部。任何想法如何在页面刷新后保持滚动位置?
{literal}
(function($){
$(window).load(function(){
/* custom scrollbar fn call */
$(".content_2").mCustomScrollbar({
scrollInertia:150;,
theme:"light";
});
});
})(jQuery);
{/literal}
您可以在此处查看图片
答案 0 :(得分:1)
在localstorage中设置它并在窗口加载时检索它:
$(window).load(function () {
// load custom scrollbar here...
var _top = localStorage.getItem('scrollPosition') || 0;
$('html, body').scrollTop(_top);
});
$(window).on('scroll', function (e) {
localStorage.setItem('scrollPosition', $(this).scrollTop());
});