JavaScript FAQ(十四)——滑鼠事件(一)

來源:互聯網
上載者:User

十二、 滑鼠事件

 

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  ) }}


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.