Right click can be disable by attaching a even listener to contextmenu
event. It can be done using jQuery or vanilla Javascript.
disable right click using jQuery
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <div id="count1">Hello world</div> <script type="text/javascript"> $(document).on("contextmenu", function(e) { console.log("right click disabled"); return false; }); </script>
Here is the log message we can see in console when someone right clicks in the document.
disable right click using vanilla Javascript
<div id="count1">Hello world</div> <script type="text/javascript"> document.addEventListener("contextmenu", function(e) { console.log("right click disabled"); e.preventDefault(); return false; }); </script>