Disable right click on web page

One has to use JavaScript to accomplish this. If the user has JS disabled, you cannot prevent the right click.

You can do it either by adding an event listener to for the “contextmenu” event and calling the preventDefault() method.


document.addEventListener('contextmenu', event => event.preventDefault());

or just by adding “oncontextmenu” to body tag.

<body oncontextmenu="return false;">

Leave a comment

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