You Might Also Want To Read: Disable “Read Only” to Windows 10 folders
Table of Headings
document.addEventListener('contextmenu', event => event.preventDefault());
Disable Right Click Using HTML Body Tag
After designing a webpage, for instance, using DreamWeaver, you can easily disable right-click by means of adding the “oncontextmenu” handler to the body tag of the webpage. When you see the source code of your newly designed webpage, search for body, add the oncontextmenu handler to it as
body oncontextmenu=”return false;.”
After that, save. It works superbly, and your content would immediately be secured as right-click would be deactivated.
Disable Right Click Using CSS
This is another very simple way to disable right-click. The fact that people don’t really know that CSS can disable text selection means that they’ll find it hard to outsmart it.
However, be aware that we aren’t necessarily disabling right-click here. We are simply deactivating the ability to select text using the user-select CSS property, therefore on right-click, no “copy” option would be visible henceforth.
For this method, I assume that the CSS region you want to deactivate right-click for is specified as a body in your CSS (body). You can add the below CSS properties to any class name you want. Combining this method with other methods means users will not be able to select text or right-click. It is left for you to decide if you’d combine or use it alone. See the snippet to add to your CSS code to disable right-click below:
-webkit-user-select: none; /* Chrome all / Safari all */
-moz-user-select: none; /* Firefox all */
-ms-user-select: none; /* IE 10+ */
Add it to your website’s CSS file and save it. “Copy” will no longer be visible anytime you right-click.
You Might Also Want To Read: How to Enable or Disable Low Data Mode on iPhone.
There you go. If you ever need to deactivate right-click on website pages without using a plugin, you already know what to do and how to go about it.