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>
Leave a Reply

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

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like