Trick to disable right click using JavaScript / jQuery

by  
Share:
Trick to disable right click using JavaScript / jQuery

Learn the trick to disable right click using JavaScript or jQuery on a webpage.

Disable right click using  jquery

<script type='text/javascript'>
jQuery(document).bind("contextmenu",function(e){
  return false;
}); 
</script>

Disable right click using  javascript

<script type="text/javascript">
    if (document.addEventListener) {
        document.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        }, false);
    } else {
        document.attachEvent('oncontextmenu', function() {
            window.event.returnValue = false;
        });
    }
</script>

This above snippet has been taken from this site

Get the latest updates directly in your inbox for FREE: Subscribe here

Share your feedback / let me know your doubts regarding this tutorial in the comment box given below.

Share:
Hasan

Shahrukh Khan (Hasan)

A software engineer who's a die-hard coder, blogger, dreamer and mentor with years of expertise in web development. Know more...

Related Posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.