JavaScript FAQ(十四)——鼠标事件(一)
2009-02-16 10:59
323 查看
十二、 鼠标事件
1. 鼠标事件属性(Mouse Event Properties )
Q:哪些事件属性我可以用来分析鼠标事件?
A:Netscape Navigator 4和Internet Explorer 4(以及较新版本)支持相当少的事件属性。其中一些在两个浏览器上是一样的(例如,event.screenX或者event.typ);不过,多数还是平台相关。移动或点击鼠标,下面的文本框会显示你当前浏览器()的所有事件属性:(译者注:由于原文实例不能正确运行,这里只贴出相关的JavaScript代码)
1. 鼠标事件属性(Mouse Event Properties )
Q:哪些事件属性我可以用来分析鼠标事件?
A:Netscape Navigator 4和Internet Explorer 4(以及较新版本)支持相当少的事件属性。其中一些在两个浏览器上是一样的(例如,event.screenX或者event.typ);不过,多数还是平台相关。移动或点击鼠标,下面的文本框会显示你当前浏览器()的所有事件属性:(译者注:由于原文实例不能正确运行,这里只贴出相关的JavaScript代码)
ns4=(navigator.appName=="Netscape" && parseInt(navigator.appVersion)>3) ? true:false; ie4=(navigator.appName!="Netscape" && parseInt(navigator.appVersion)>3) ? true:false; serialN=0; function handlerFoo(e) { if (parseInt(navigator.appVersion)>3) { evt = ns4 ? e:event; var str=''; for (var k in evt) {str+='event.'+k+'='+evt[k]+'/n'} if (''+evt.type==''+self.document.f1.s1.options[self.document.f1.s1.selectedIndex].value) self.document.f1.t1.value=str; if (''+evt.type==''+self.document.f2.s2.options[self.document.f2.s2.selectedIndex].value) self.document.f2.t2.value=str; self.status='Number of events handled: '+serialN; serialN++; } return true; } if (parseInt(navigator.appVersion)>3) { document.onmousedown=handlerFoo; document.onmouseup=handlerFoo; document.onmouseover=handlerFoo; document.onmouseout=handlerFoo; document.onmousemove=handlerFoo; document.onclick=handlerFoo; if (navigator.appName=="Netscape") { document.captureEvents( Event.MOUSEDOWN | Event.MOUSEUP | Event.MOUSEMOVE | Event.MOUSEOVER | Event.MOUSEOUT | Event.CLICK ) } }
相关文章推荐
- JavaScript FAQ(十六)——鼠标事件(三)
- javascript基础四 (事件应用鼠标滚轮)
- javascript事件列表大全解说,点击事件,双击事件,触发事件,键盘事件,鼠标移...
- Javascript:DOM事件(监听鼠标点击/释放,鼠标悬停/离开等)
- javascript鼠标滚动事件详解及应用
- javascript屏蔽鼠标、键盘事件
- Web小练习-JavaScript事件的简单练习,监听鼠标的移动
- JavaScript中的鼠标滚轮事件详解
- javascript的鼠标键盘事件
- javascript 不让鼠标事件触发
- JavaScript——鼠标点击事件
- javascript鼠标事件学习
- JavaScript 鼠标事件
- JavaScript鼠标事件对象的坐标属性整理
- 关于JavaScript中监听鼠标滚轮事件
- JavaScript和JQuery的鼠标mouse事件冒泡处理
- JavaScript鼠标事件2
- javascript 处理鼠标右键事件
- javascript鼠标滚轮事件
- 解析javascript中鼠标滚轮事件