javascript - 使用鼠标中键滚动按钮禁用浏览器滚动

标签 javascript flash scroll mousewheel

我的页面上有一个 flash 元素,您可以使用鼠标中间的滚轮与之交互。页面很长。因此,当使用鼠标滚轮滚动时,它会与 Flash 元素交互并滚动浏览器窗口。

有没有办法在 Flash 元素处于事件状态时禁用浏览器滚动?

最佳答案

<!-- 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>

我已经从 Flash MouseWheelTrap 中“提取”了这个函数,可以在这里找到: http://code.google.com/p/mousewheeltrap/

关于javascript - 使用鼠标中键滚动按钮禁用浏览器滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2554030/

相关文章:

javascript - 事件被绑定(bind)两次或多次jquery

actionscript-3 - YouTUBE API for Flash不起作用

flash - RobotLegs 域逻辑 - 将其放置在何处

jquery - IE8 定位 DIV 覆盖错误并在隐藏时继续播放视频

css - Chrome 中的网站滚动速度非常慢,如何解决?

javascript - 如何使列表从下到上动画化

javascript - 粘性导航未正确添加事件链接

javascript - 映射数据时避免 'Cannot read property of undefined' 错误

javascript - Axios - 在不实际发出请求的情况下获取带有参数的 url

php - 使用jquery从插入到src标记的html输入字段中获取值