Prevent Content Theft By Disabling Text Selection

Prevent Content Theft By Disabling Text Selection
File Size: 6.08 KB
Views Total: 85
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

This is a cross-browser jQuery content copy protection solution that prevents content theft from your website by using HTML unSelectable attribute, CSS user-select property, and JavaScript selectstart event.

See Also:

How to use it:

1. The main function that disables content selection. Copy and paste the following JS snippets after jQuery.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
(function($){
  $.fn.disableSelection = function() {
    return this
    .attr('unselectable', 'on')
    .css('user-select', 'none')
    .on('selectstart', false);
  };
})(jQuery);

2. Disable text selection on the entire page.

$(function(){
  $('body').disableSelection();
});

3. Or on a specific container.

$(function(){
  $(''.container').disableSelection();
});

This awesome jQuery plugin is developed by habeebuddinhuzaifa. For more Advanced Usages, please check the demo page or visit the official website.