How To Disable Right Click Using jQuery

Posted by Lasantha Bandara File Under : java script, jquery 17 Comments

This article explains to you how to disable right click function using a simple jQuery code snippet. If you like to add this feature to your site, then follow the steps below.

1.Login to your blogger account and go to "Edit HTML".

2.Scroll down to where you see </head> tag .

3.Copy below code and paste it just before the </head> tag.

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js' type='text/javascript'></script>
<script src='http://code.jquery.com/jquery-migrate-1.2.1.js'></script>

<script type='text/javascript'>
//<![CDATA[

jQuery(document).ready(function($) {
    $(document).bind("contextmenu", function(e) {
        return false;
    });
});

//]]>
</script>

NOTE : If jQuery is already included into your theme remove these lines from the above code:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js' type='text/javascript'></script>
<script src='http://code.jquery.com/jquery-migrate-1.2.1.js'></script>

4.Now save the template. Refresh your site and try to right click on your website or blog.

17 thoughts on “How To Disable Right Click Using jQuery

  1. YEHEY! It worked for me!

    http://travel-on-a-shoe-string.blogspot.com

    Thank you Lasantha! You're the best!

  2. Nice trick to disabling the text on blogger.. I intend to apply on my blog then, thanks for the tutorial 🙂

  3. It works but if you hit F5 and then quickly right click you can bypass the script before it gets a chance to re-load. It's impossible to protect images without a watermark anyway but nice simple code example :O)

Leave a Reply

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

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