最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - How lockunlock mouse scroll on PHPhtmlJavascript? - Stack Overflow

programmeradmin3浏览0评论

In my project I have a dialog window that arrears when user clicks on link

<a href="javascript:;" onclick="flashnotice()" >Dialog window</a>

Then window appears it runs Javascript function flashnotice() and in this function I need to blocked mouse scroll, and when user close this window (user clicks on image) mouse scroll release, I prefer listening this image on jQuery and when be a click run new Javascript function that release mouse scroll.

In my project I have a dialog window that arrears when user clicks on link

<a href="javascript:;" onclick="flashnotice()" >Dialog window</a>

Then window appears it runs Javascript function flashnotice() and in this function I need to blocked mouse scroll, and when user close this window (user clicks on image) mouse scroll release, I prefer listening this image on jQuery and when be a click run new Javascript function that release mouse scroll.

Share Improve this question edited Apr 14, 2020 at 15:28 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Aug 3, 2011 at 7:46 Darien FawkesDarien Fawkes 1191 gold badge5 silver badges16 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

You can set style="overflow:hidden" on body tag when box appears. It will lock mouse scroll or use position:fixed on a box.

The best way to "freeze" a page is to make transparent or half transparent box (100% width, 100% height) between a page and your box and set position:fixedto your box. This is the way Lightbox/Fancybox works.

Actually you cannot lock scrolling, you can use CSS fixed/absolute positioning feature to fix position of your element.

I think that it is possible using a script like :

function kill(event)
{
    event.preventDefault();
    event.stopPropagation();
    return false;
}
$(document).bind('scroll', kill); // Lock Wheel
$(document).unbind('scroll'); // Unlock Wheel
发布评论

评论列表(0)

  1. 暂无评论