Search code examples
javascripthtmlinternet-explorerright-clickonmouseup

Whats wrong with my mouseup code?


Trying to detect left click vs right click (without using jQuery!) and I have the following code

Javascript:

function cclick(e) {
   if (e.button == 1) {alert("hgbdygwea");}
   else {
      alert(e.button);
   }
}

HTML:

<a onmouseup="cclick()" ...> <img .../> </a> <!-- also tried cclick instead of cclick() -->

using internet explorer 9


Solution

  • You need to pass the event object to your function:

    onmouseup="cclick(event);"