Showing posts with label how to disable right click menu in html page using jquery. Show all posts
Showing posts with label how to disable right click menu in html page using jquery. Show all posts

Thursday 2 April 2015

Disable right click menu in html page using jquery


Disable Right click from webpages
<script type="text/javascript" language="javascript">
        $(function() {
            $(this).bind("contextmenu", function(e) {
                e.preventDefault();
            });
        }); 
    </script>
Disable Right click to Images only.

document.addEventListener("contextmenu", function(e){
    if (e.target.nodeName === "IMG") {
        e.preventDefault();
  alert('Right Click Not Allowed !!!');
    }
  }, false);