Javascript code to disable mouse right click

You could use Javascript code to disable mouse right click on the webpage. This article demonstrates two methods to disable the context menu with the right click of a mouse button.

Though disabling right-click option is not a complete solution to save the data, but it will make the task difficult or maybe impossible for the rookies.

Javascript code to disable mouse right click

<script language="javascript">
document.onmousedown=disableRightclick;
status="Disabled";
function disableRightclick(event)
{
  if(event.button==2)
   {
     alert(status);
     return false;    
   }
}
</script>

Javascript prevents mouse right click menu

<body oncontextmenu="return false">
...
</body>

0 Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like
XOR in Python

XOR in Python

XOR Operator in Python is also known as “exclusive or”  that compares two binary numbers bitwise if two bits are…
How To

How to configure Git proxy?

If you are working in the corporate company all the internet requests usually goes through the corporate firewall.…