How lock/unlock mouse scroll on PHP/html/Javascript?
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 blocke开发者_如何转开发d 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.
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:fixed
to 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
精彩评论