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.

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like
How To Get File Size In Python

How to Get File Size in Python?

Table of Contents Hide Python get file sizeMethod 1: Get file size using os.path.getsize()Method 2: Get file size using os.stat()Method 3: Get file size using seek() and tell()Method 4: Get…
View Post