How to prevent right click on a web browser with JavaScript

Sometimes we are so selfish enough that we feel disabling right click functionality on our website is necessary, although there are many users that will find a way to keep stealing our contents.

This is a simple script to prevent context menu being displayed (to prevent right click) on our website:

window.addEventListener('contextmenu', function (e) { 
  // do something here... 
}, false);

Leave a Reply

Your email address will not be published.