Protect your page from Copy, Paste, Cut, Drag, Select

Using Jquery you can protect your page from copy past, drag, image select and it’s also compatible with all browse. (IE. Firefox, Chrome) Add this script in $(function (){ }); or $(document).ready(function() { }); It also disables right-click so that copy paste will not be available
    $(function() {
        $.extend($.fn.disableTextSelect = function () {
            return this.each(function () {
                if($.browser.mozilla) {//FF
                    $(this).css(‘MozUserSelect’, ‘none’);
                } else if ($.browser.msie) {//Internet
                    $(this).bind(‘selectstart’, function() {return false; });
                } else{//Others, etc.
                    $(this).mousedown(function () { return false; });
                }
            });
        });
        $(‘#divID’).disableTextSelect();
//No text selection on elements with a class of
‘noSelect’
    });
One more simple solution

$(“img”).mousedown(function() {
        return false;
});
One more relevant question how to disable copy, paste and cut in textbox or input type text? This feature useful in username password copy past

$(document).ready(function() {
        $(‘#txtInput’).bind(“cut copy paste”, function (e) {
            e.preventDefault();
        });
    });
Advertisements
This entry was posted in jQuery and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s