Tryit Editor v1.4

<html> <head> <script type="text/javascript"> function whichButton(event) { if (event.button==2) { alert("You clicked the right mouse button!"); } else { alert("You clicked the left mouse button!"); } } </script> </head> <body onmousedown="whichButton(event)"> <p>Click in the document. An alert box will alert which mouse button you clicked.</p> </body> </html> | Your Result:
Edit the code above and click to see the result. | W3Schools.com - Try it yourself