How To Disable Right Click Using jQuery

Posted by Lasantha Bandara on October 28th, 2015 File Under : java script, jquery17 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.

File Under : java script, jquery

17 Responses to “How To Disable Right Click Using jQuery”

  1. Beben says:

    hehehe...some people added no right click trick, you created disable it...so creative...good good

  2. maddy says:

    didn't work for me Lasantha Bandara,

    http://desimasalawood.blogspot.com

  3. Rodrigo Medeiros says:

    It works! I love it!
    www.Sonhos-Concretizados.pt.vu ^^

  4. ehtrthj says:

    tanks for this! how did u put the reply at comments?

  5. Injun Jim says:

    didn't work for me

  6. Rojin Giri says:

    Hey,
    It didn't work with my blog
    http://littlewordsthatcount.blogspot.com

  7. Desibaba says:

    Great simple code. Thank you. It is working.

  8. Bon Jovi says:

    it rocks !!! work for me ..

    http://theworldaccordingto-bon.blogspot.com

  9. isare says:

    work for me..thanks

    www.ertihidup.com

  10. Anonymous says:

    works for me http://brainhosting.blogspot.com/

    10x

  11. KiranKumar Roy says:

    thanks a lot.
    it works for me..

    http://velements-gallery.co.nr/

  12. KK says:

    Superb Works For me

    Www.appswithserial.blogspot.com

  13. Maarja says:

    Works perfectly!

  14. Varinder Pal Singh says:

    Wow Amazing It 100% Works Thankssss

  15. travelonashoestring says:

    YEHEY! It worked for me!

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

    Thank you Lasantha! You're the best!

  16. Pakualam says:

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

  17. Colin says:

    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.