How to disable right-click in JavaScript

In this tutorial, we are going to see how to disable the right-click in JavaScript. You can disable the right-click context menu on a web page for various reasons. This could be to display a custom pop-up menu or to prevent the user from saving images, etc.

Script to disable right-click in JavaScript:

Include the following JavaScript code snippet in your web page.

document.oncontextmenu = function() {
  return false;
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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