Disable Mouse Right click | Cut | Copy | Paste in jQuery
The following example shows, how to avoid copying content from your website, by disabling the mouse right click, cut, copy and paste in juery.
Disable mouse right-click event on the entire web page:
contextmenu
event is used to disable the right-click.e.preventDefault()
event handler is used to prevent the default behavior.
Example
<script> $(document).ready(function(){ $(this).on('contextmenu', function(e){ e.preventDefault(); }); }); </script>Try it Yourself
Disable mouse right-click event on particular part of the web page:
- Disable the right-click event on particular part of the web page using id, class or element.
Example
<script> $(document).ready(function(){ $("#demo").on('contextmenu', function(e){ e.preventDefault(); }); }); </script>Try it Yourself
Disable Cut, Copy & Paste on entire web page:
- Disable the cut(CTRL+X), copy(CTRL+C) & paste(CTRL+P) on particular part of the web page using id, class or element.
Example
<script> $(document).ready(function(){ $(this).on('cut copy paste', function(e){ e.preventDefault(); }); }); </script>Try it Yourself
Disable Cut, Copy & Paste on particular part of the web page:
- Disable the cut(CTRL+X), copy(CTRL+C) & paste(CTRL+P) on particular part of the web page using id, class or element.
Example
<script> $(document).ready(function(){ $("#demo").on('cut copy paste', function(e){ e.preventDefault(); }); }); </script>Try it Yourself