怎么判断鼠标左键按下后再滚动滚轮? 直接好象不行吧?我知道的只能判断鼠标左右键。不知道这样行不行,在鼠标左键按下以后为为设置window的onscorll函数只要函数执行应该就是按下左键后滚动滚轮了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 FF 不支持多键同时按下的捕捉你可以去 x-bs.com 的扫雷里看下源文件 <script>//ff没测试过,ff按键值和ie表示不同var FirstButton=null;document.onmousedown=function(e){ e=e||event; if(FirstButton==null) { FirstButton=e.button;//记住第一次按下的鼠标键 } else { if(FirstButton==1&&e.button==5) alert('按下了左键后按下滚轮!'); }}document.onmouseup=function(){FirstButton=null;}</script> <div id="dvState"><script>var st=null;var top=null;document.onmousedown=function(e){ e=e||event; if(e.button==1) { top=document.body.scrollTop; st=setInterval(checktop,50); }}document.onmouseup=function(){if(st)clearInterval(st);}function checktop(){ if(document.body.scrollTop>top) window.status="按下左键并且向下滚动"; else if(document.body.scrollTop<top) window.status="按下左键并且向上滚动"; //else window.status=""; top=document.body.scrollTop;}</script><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>1<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br<br>2 那没办法了,好象没有判断滚轮方向的事件就算是window.onscroll也是要页面能滚动 function gd(evt){ evt=evt?evt:event; if (event.wheelDelta<120) { if (event.button==1){ alert("按下向下"); }else { document.getElementById('_xia').click(); }}else { if (event.button==1){ alert("按下向上"); }else { document.getElementById('_sh').click(); } }}我这样写的话,在松开鼠标的时候。鼠标的状态还是处于按下状态。 原来我这个方法是对的。。谢谢showbo 遇到一个有点奇怪的问题 通过sendEvent控制jwPlayer无效 如何用js动态给tr增加事件 setInterval在类中如何使用? 求漂浮窗口(内嵌html页)? 为什么这个判断不成立它还是会执行?? javascript中的事件(或函数)的参数如何传递(诸如整型等)指针或者引用? 如何才能实现左边导航条菜单的样子?(www.csdn.net 左边的) 哇,老孟,我真是服了你了 localstorage 使用js实现下拉菜单功能,但在firefox浏览器上无法体现 各位高手帮我看一下.这个JS什么地方出错了.
//ff没测试过,ff按键值和ie表示不同
var FirstButton=null;
document.onmousedown=function(e)
{
e=e||event;
if(FirstButton==null)
{
FirstButton=e.button;//记住第一次按下的鼠标键
}
else
{
if(FirstButton==1&&e.button==5)
alert('按下了左键后按下滚轮!');
}
}
document.onmouseup=function(){FirstButton=null;}
</script>
<script>
var st=null;
var top=null;
document.onmousedown=function(e)
{
e=e||event;
if(e.button==1)
{
top=document.body.scrollTop;
st=setInterval(checktop,50);
}
}
document.onmouseup=function(){if(st)clearInterval(st);}
function checktop()
{
if(document.body.scrollTop>top)
window.status="按下左键并且向下滚动";
else if(document.body.scrollTop<top)
window.status="按下左键并且向上滚动";
//else window.status="";
top=document.body.scrollTop;
}
</script>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>1
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br<br>2
evt=evt?evt:event;
if (event.wheelDelta<120) {
if (event.button==1){
alert("按下向下");
}else {
document.getElementById('_xia').click();
}
}
else {
if (event.button==1){
alert("按下向上");
}else {
document.getElementById('_sh').click();
}
}
}我这样写的话,在松开鼠标的时候。鼠标的状态还是处于按下状态。