Created
May 4, 2010 16:36
-
-
Save nathany/389625 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////////////////// | |
// | |
// jquery.protect.js | |
// Copyright (c) 2010 Yardstick Software | |
// | |
// This plugin allows you protect a page from selection/copying the text. | |
// | |
// Doesn't do anything about Print Scrn, Save As... | |
// | |
/////////////////////////////////////////////////////////////////////////////// | |
(function($) { | |
$.fn.protect = function() { | |
// prevent the text from being copied (Firefox, Safari) (IE doesn't fire when targetting the document) | |
$(document).bind('copy', function(e){ return false; }); | |
// Prevent the text from being selected (handles most things, but not Ctrl+A, Ctrl+C in Firefox, Safari, which above handles) | |
$('body').css("-moz-user-select", "none") | |
$().attr("unselectable", "on") | |
.bind("selectstart.ui", function() { | |
return false; | |
}); | |
return this; | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment