Disable Right Click
The standard defense for webmasters. This script intercepts the right mouse button click and returns `false`, effectively canceling the menu display.
Right-clicking in this area is disabled.
Go ahead, try it inside the gray box above.
Copy the Script
<script>
function disableClick(event) {
if (event.button == 2) { // 2 is the right mouse button
return false;
}
}
document.oncontextmenu = function() { return false; };
</script>
Frequently Asked Questions
They perform the same function. This is simply the most standard, widely-used implementation using the 'oncontextmenu' event handler.
Possibly. Users often right-click to open links in new tabs. We recommend only using this on specific elements (like an image gallery) rather than the whole page.
Yes. You can add an 'alert()' inside the function to tell users why the menu is disabled (e.g., 'Copyright Protected').