How To Disable Right Click on A Webpage?

Date Published: 28/08/2020 Published By: JaiSchool

By using oncontextmenu event and write return false; statement in its function's body.

<!DOCTYPE html>
<html>
<head>
  <title>Right click is disabled</title>
</head>
<body>

  <h1 align="center">Right click is disabled on this webpage!!!</h1>

  <script>
  document.oncontextmenu=function()
  {
    alert("This action is prohibited on this webpage.");
    return false;
  }
  </script>
</body>
</html>

Or use attribute oncontextmenu attribute.

<!DOCTYPE html>
<html oncontextmenu="alert('This action can not be performed.');return false;">
<head>
  <title>Right click is disabled</title>
</head>
<body>

  <h1 align="center">Right click is disabled on this webpage!!!</h1>

</body>
</html>

Other Articles~

Publish A Comment

Leave a Reply

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