'button' Example : Mouse « Event « JavaScript DHTML






'button' Example

 
    
<html>
<body>
<script language="JavaScript">
    function function1() {
        var m = window.event.button;
        if (m == 1) { 
            alert("The left button has been pressed"); 
        } else if (m == 2) { 
            alert("The right button has been pressed"); 
        }
    }
</script>
<div style="width:200; 
            height:200; 
            background-color:blue; 
            color:white;" 
     onmousedown="function1();">
Press on mouse while on top of this blue box.
</div>
</body>
</html>

    
      
        
  








Related examples in the same category

1.Mouse wheel Delta
2.Get X/Y screen position (IE)