disable right click in html code example

Example 1: disable right click

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

Example 2: how to disable right click in javascript

// for disabling right click use this as it is 
document.addEventListener('contextmenu', event => event.preventDefault());
event.preventDefault()

Example 3: disable right click div

This is the Phone and NO ONE SHOULD RIGHT CLICK THIS! >:)




And this is the Keyboard, ofcourse yo can right click this :)
$('img').bind('contextmenu', function(e){ alert("This Logo is protected");return false; });

Tags:

Misc Example