Content Copy Protection by Using Simple Javascript

I just want to share content copy protection by using a few lines of javascript. You can freely modify the script based on your needs.

The first thing you must not forget is adding jQuery inside <head> tag. Enough, here is the script.

/* I use jQuery 1.7.1 */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type = "text/javascript">
(function ($) {
  if ($.browser.mozilla) {
    $.fn.disableTextSelect = function () {
      return this.each(function () {
        $(this).css({
          'MozUserSelect': 'none'
        })
      })
    };
    $.fn.enableTextSelect = function () {
      return this.each(function () {
        $(this).css({
          'MozUserSelect': ''
        })
      })
    }
  } else if ($.browser.msie) {
    $.fn.disableTextSelect = function () {
      return this.each(function () {
        $(this).bind('selectstart.disableTextSelect', function () {
          return false
        })
      })
    };
    $.fn.enableTextSelect = function () {
      return this.each(function () {
        $(this).unbind('selectstart.disableTextSelect')
      })
    }
  } else {
    $.fn.disableTextSelect = function () {
      return this.each(function () {
        $(this).bind('mousedown.disableTextSelect', function () {
          return false
        })
      })
    };
    $.fn.enableTextSelect = function () {
      return this.each(function () {
        $(this).unbind('mousedown.disableTextSelect')
      })
    }
  }
})(jQuery);
jQuery(function ($) {
  $('YOUR_CLASS_OR_ID_HERE').disableTextSelect()
});
</script>

Setting Up

At line 49 you can see YOUR_CLASS_OR_ID_HERE, you have to change it to your content container ID or class. It is to determine which content that you want to copy protect.

Remember to add # before ID name, and . before class name. For example:

/* ID */
$('#the-content').disableTextSelect();

/* CLASS */
$('.the-content').disableTextSelect();

That’s it, Hope it helps. Any question just ask.