【发布时间】:2017-06-20 03:21:37
【问题描述】:
我有这个代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
window.addEventListener('DOMMouseScroll', mouseWheelEvent);
window.addEventListener('mousewheel', mouseWheelEvent);
function mouseWheelEvent() {
alert(1);
}
</script>
</body>
</html>
它适用于 Chrome 和 Firefox。但是,它不适用于我的笔记本电脑 dell xps 13 9434 在 IE 和 edge 中的触摸板。但它确实适用于(某些)其他笔记本电脑的触摸板。该怎么办? jQuery 没问题。
“什么不起作用?” => 使用 2 根手指(就像您在浏览器中滚动一样)时,滚动不会出现警报。
【问题讨论】:
-
根据您从滚动事件接收到的信息类型,您可以将其与
touchstart、touchend、touchmove事件组合/替换。更多详情请见mozilla docs
标签: javascript internet-explorer mouseevent multi-touch microsoft-edge