Handle both left and right click event (onclick) action - Javascript DOM Event

Javascript examples for DOM Event:onclick

Description

Handle both left and right click event (onclick) action

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
        function handleRightClick() {
            console.log("Got right click!");
        };/* w ww  . j  a va  2  s.  com*/
        function handleLeftClick() {
            console.log("Got left click!");
        };
    
      </script> 
   </head>
   <body> 
      <img src="http://www.java2s.com/style/download.png" onclick="handleLeftClick(this);" oncontextmenu="handleRightClick(this); return false;">  
   </body>
</html>

Related Tutorials