function debounce(method,delay) {
let timer = null;
return function () {
let self = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
method.apply(self,args);
},delay);
}
}
window.onscroll = debounce(function () {
let scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
localStorage.setItem('scrollTop',scrollTop)
},200)
$(document).ready(function() {
$('html,body').animate({
scrollTop:top
},100)
})
刷新页面后滚动条位置保持不变
最新推荐文章于 2022-11-10 10:39:45 发布