1个回答
展开全部
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JavaScript判断鼠标滚轮滚动方向- www.fengfly.com </title>
<script type="text/javascript">
function handle(delta) {
var s = delta + ": ";
if (delta <0)
s += "您在向下滚……";
else
s += "您在向上滚……";
document.getElementById('delta').innerHTML = s;
}//from www.fengfly.com
function wheel(event){
var delta = 0;
if (!event) event = window.event;
if (event.wheelDelta) {
delta = event.wheelDelta/120;
if (window.opera) delta = -delta;
} else if (event.detail) {
delta = -event.detail/3;
}
if (delta)
handle(delta);
}
if (window.addEventListener)
window.addEventListener('DOMMouseScroll', wheel, false);
window.onmousewheel = document.onmousewheel = wheel;
</script>
</head>
<body>
<div id="delta">滚动中轮试试~请选按着中轮滚动,激活后可以不按,直接滚动。 </div>
<p>shared by http://www.111cn.net</p>
</body>
</html>
追问
我想要的是类似于手指滑动,不是鼠标滚轮。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询