开发者

Disable browser scrolling with the middle mouse scroll button

开发者 https://www.devze.com 2022-12-25 11:04 出处:网络
I have a flash element on my page that you interact with by using the开发者_如何转开发 middle mouse scroll wheel. The page is long. So when scrolling with the mouse wheel it interacts with the Flash e

I have a flash element on my page that you interact with by using the开发者_如何转开发 middle mouse scroll wheel. The page is long. So when scrolling with the mouse wheel it interacts with the Flash element AND scrolls the browser window.

Is there a way to disable browser scrolling while the Flash element is active?


<!-- disables browser mouse scrolling -->
<script type="text/javascript">
if(window.addEventListener){
    window.addEventListener('DOMMouseScroll',wheel,false);
}

function wheel(event)
{
    event.preventDefault();
    event.returnValue=false;
}
window.onmousewheel=document.onmousewheel=wheel;
</script>

I have "extracted" this function from the Flash MouseWheelTrap which can be found here: http://code.google.com/p/mousewheeltrap/


You can use:

document.body.style.overflow=allowScroll?"":"hidden";

Where allowScroll is a boolean.


window.onscroll = function() {
    document.body.scrollTop = 0;
}


SWFWheel: http://www.libspark.org/wiki/SWFWheel/en

0

精彩评论

暂无评论...
验证码 换一张
取 消