Disable mouse right click, cut, copy and paste using jQuery

Are you want to prevent visitors from copying your web page content? In this short jQuery article, we’ll show you how to stop content theft from your website using jQuery. For stopping the content copy of your website you can do two things, one is to disable the mouse right click and second is to disable the cut (CTRL+X), copy (CTRL+C) and paste (CTRL+V). Using of jQuery, you can easily disable mouse right click and disable cut, copy and paste from web content.

disable-mouse-right-click-cut-copy-paste-using-jquery-by-codexworld

At first include the jQuery library.

<script src="jquery.min.js"></script>

Disable Mouse Right Click

Disable mouse right click will prevent visitors from choosing the cut, copy and paste options. If you want to disable right mouse click for a particular section of a web page, then you can use a selector (#id, .class, etc.) otherwise use body selector for the full page. The following JavaScript code is used to disable mouse right click.

<script type="text/javascript">
$(document).ready(function () {
    //Disable full page
    $("body").on("contextmenu",function(e){
        return false;
    });
    
    //Disable part of page
    $("#id").on("contextmenu",function(e){
        return false;
    });
});
</script>

Disable Cut Copy & Paste

The following JavaScript code will disable cut, copy and paste from your web page or a part of your web page.

<script type="text/javascript">
$(document).ready(function () {
    //Disable full page
    $('body').bind('cut copy paste', function (e) {
        e.preventDefault();
    });
    
    //Disable part of page
    $('#id').bind('cut copy paste', function (e) {
        e.preventDefault();
    });
});
</script>

Disable Mouse Right Click, Cut, Copy & Paste

Full JavaScript code for disabling mouse right click and disable cut (CTRL+X), copy (CTRL+C) and paste (CTRL+V) from the web page.

<script type="text/javascript">
$(document).ready(function () {
    //Disable cut copy paste
    $('body').bind('cut copy paste', function (e) {
        e.preventDefault();
    });
   
    //Disable mouse right click
    $("body").on("contextmenu",function(e){
        return false;
    });
});
</script>

Do you want to get implementation help, or enhance the functionality of this script? Click here to Submit Service Request

46 Comments

  1. Noorien Said...
  2. Web Digiworld Said...
  3. Maffix Said...
  4. Hafiz Morsalin Said...
  5. Mona Said...
  6. Sunil Said...
  7. Let Management Said...
  8. Kunal Paliwal Said...
  9. Shikha Namdhari Said...
  10. Jahid Said...
  11. Teja Said...
  12. Sameed Al Wazir Said...
  13. Vijay Said...
  14. Steve RR Said...
  15. Saransh Sagar Said...
  16. Jean Said...
  17. Latest Government Jobs Said...
  18. Sumit Kesharwani Said...
  19. Kisakye Paul Said...
  20. Jake Said...
  21. Shashikant Said...
  22. Teckoveda Said...
  23. Marlon Sanico Said...
  24. Karampal Singh Said...
  25. CB Ezhil Kumar Said...
  26. Eneza Said...
  27. Rahul Said...
  28. Jenny Said...
  29. Godti Vinod Said...
  30. Steve Said...
  31. Krishanya Said...
  32. Nansal Fernandes Said...
  33. Anne Francis Scott Said...
  34. Sakil Said...
    • CodexWorld Said...
  35. Carla Said...
  36. Anas Said...
  37. Djong Timoer Said...
    • CodexWorld Said...
  38. Namrata Said...
  39. Yogesh Singh Said...
  40. Mayur Dhudasia Said...

Leave a reply

keyboard_double_arrow_up