본문 바로가기

[IT/Programming]/HTML related

Mouse click 들 (left, right, wheel, wheel up, wheel down, back, forward) 구분해내기

728x90
반응형
# Mouse click 들 (left, right, wheel, wheel up, wheel down, back, forward) 구분해내기 ## PH
  • 2023-10-24 : First posting.
## TOC ## Test
Result
Wheel click 으로 새창이 안열리게 하려면 a tag 의 href 를 제거해주면 됨. ## Code ```[.linenums.lang-html] <div class="center" id="click-me" style="font-size:3em; border:5px solid wheat; background:rgb(200,200,255); width:100%; padding:2em 1em"><a id="a-click-me" style="color:rgb(255,200,200)">Click me</a></div> <div id="result">Result</div> <script> window.m=window.m||{}; m.onFunction=function (event) { console.log(event); event.preventDefault(); event.stopPropagation(); $("#result").html(`event: ${event}<br>event.type: ${event.type}<br>event.which: ${event.which}<br>event.button: ${event.button}<br>event.buttons: ${event.buttons}`); }; $("#click-me").on("click dblclick mouseup mousedown wheel scroll", m.onFunction); $("#a-click-me").on("click dblclick mouseup mousedown wheel scroll", function (e) { e.preventDefault(); }); </script> ```/ ## RRA
  1. kipid's blog :: HTML a href tag with onclick return
  2. kipid's blog :: HTML event handler
  3. kipid's blog :: Specific event handler on HTML element?
  4. Mouse Test

  5. www.onlinemictest.com :: MOUSE TEST
  6. devicetests.com :: Mouse Button Click Test
728x90
반응형