Question: How to disable right click on the website using javascript
Answer:
We will learn all the simplest methods that help us to 'disable right click'. So let's get started to learn.
First: using 'document.addEventListener()' concept.
document.addEventListener('contextmenu', event => event.preventDefault());
Second: this method is similar to the previous method, we just add a function to disable right click.
document.addEventListener("contextmenu", function(e){ e.preventDefault(); }, false);
We try to provide you the best content, if there is any mistake in this article or there is any mistake in code, then let us know.
Comments
Post a Comment