How do disable right click in Java Script

Disable full page 
                    

<html>
<head>
<title>Codelizar</title>

<script src=”https://code.jquery.com/jquery-3.4.1.js”></script>

<script type=”text/javascript”>
$(document).ready(function () {
$(“body”).on(“contextmenu”,function(e){
return false;
});
</script>

</head>
<body>
<h1>Right click disabled at whole page using body tag</h1>
</body>
</html>

 

Disable Particular a div tag
                    

<html>
<head>
<title>Codelizar</title>

<script type=”text/javascript”>
$(document).ready(function () {
$(“#img_id”).on(“contextmenu”,function(e){
return false;
});
});
</script>

</head>
<body>
<h1>Right click disabled at image tag using image id</h1>

<img  id=”img_id” src=”https://codelizar.com/wp-content/uploads/2019/08/fifthflour.png”>
</body>
</html>

Leave a Reply

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