How to disabled the right click on webpage by using jquery

If you want to disabled the right click on entire website or particular div.First you need to load the Jquery file
Disable the right click on entire web page
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>   
  <script type="text/javascript">   
   $(function () {   
   $(document).bind('contextmenu', function (e) {   
    e.preventDefault();     
   });   
   });   
  </script>
Disable the right click on perticular division (div tag)
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>  
 <script type="text/javascript">  
   $(function () {  
    $('.Container').bind('contextmenu',function(e){  
    e.preventDefault();  
    alert('Right Click is not allowed on div');  
    });  
   });  
  </script> 
Html code
 <div class="Container">  
   div content  
 </div>

* If you like this post please don’t forget to subscribe Techies Badi - programming blog for more useful stuff


EmoticonEmoticon