Which mouse button was clicked? : Mouse Event : Event onMethod JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Event onMethod » Mouse Event »

 

Which mouse button was clicked?



<html>
<head>
<script type="text/javascript">
function whichButton(event){
    if (event.button==1){
        alert("You clicked the left mouse button!")
    }else{
        alert("You clicked the right mouse button!")
    }
}
</script>
</head>

<body onmousedown="whichButton(event)">
<p>Click in the document. </p>
</body>

</html>



           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Event onMethod
» Mouse Event