Block scroll when Lightbox appears

余生长醉 提交于 2019-12-06 10:26:18

问题


I use DOM window script for Lightboxes on my website. Is there any way to block scroll on main page when Lightbox appears and unblock when it disappears?

Or, maybe, you can advice better Lightbox script?

Thanks.


回答1:


User this to disable or enable window scrollbar :

document.body.style.overflow="hidden";

on show your lightbox and

document.body.style.overflow="visible";

on hiding your lightbox.

but if your are really looking for a better lightbox library you can try this jQuery plugin :

jQuery Lightbox Plugin



来源:https://stackoverflow.com/questions/5527663/block-scroll-when-lightbox-appears

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!