Right-clicking brings up the context menu in most standard browsers; therefore, you can use the oncontextmenu listener to handle right-clicks. The listener should return false if you do not want it to display the standard browser context menu after calling your JS code.
Here is an example html that handles left and right clicks on an image.
<html>
<head>
<script type="text/javascript">
function handleRightClick() {
alert("Got right click!");
};
function handleLeftClick() {
alert("Got left click!");
};
</script
</head>
<body>
<img src="http://thefuturebuzz.com/pics/the-matrix.jpg" onclick="handleLeftClick(this);" oncontextmenu="handleRightClick(this); return false;" />
</body>
</html>
For more information check out http://www.w3schools.com/html5/html5_ref_eventattributes.asp
source
share