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.

Eg:

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

or just by adding “oncontextmenu” to body tag.

<body oncontextmenu="return false;">

Leave a Comment