弹窗下面的页面滚动问题

let bodyEl = document.body

let top = 0
 
function stopBodyScroll (isFixed) {
 if (isFixed) {
 top = window.scrollY
 
 bodyEl.style.position = 'fixed'
 bodyEl.style.top = -top + 'px'
 } else {
 bodyEl.style.position = ''
 bodyEl.style.top = ''
 
 window.scrollTo(0, top) // 回到原先的top
 }
}
posted @ 2020-05-18 17:51  慕东  阅读(297)  评论(0编辑  收藏  举报