Hey! do you know HTML has its own way of using a special attribute to disable the right click on the website or any specific section?
No?
Don’t worry!!!
I will tell you in this trick how you can disable the right click on the whole web page or any section that you only want on that.
It is very simple to disable the right click using the HTML attribute. You just have to pass the oncontextmenu
attribute to the body tag with returning value false
. See the following code.
To disable right click on full website
Using the above HTML attribute with a body tag will disable the right click on the full website.
To disable right click on specific section
If you want to disable right-click only on specific sections like header, footer, navbar, sidebar, etc. Then you can also do that with this attribute. You just have to add that attribute for that specific section.
The above example code will disable the right-click on the aside tag.
See Also: Disable right-click with jQuery
Being Tricky 😉