Jquery script to append url into copied text on clipboard


Now day automated copying of content of websites is very common and their is no fool proof way to prevent this. But you can do one thing as most of these type of program are browser based you can tweak copying of content by appending you page url to copied content.

Here  is very simple Jquery function to do this. Just replace content-wrapper selector with yours and initialize this at appropriate location.

$(".content-wrapper").bind(\'copy\', function() {
    var sel = window.getSelection();
            var pagelink = "<br />© bimbim.in Source: <a href=\'" + document.location.href + "\'>" + 

document.location.href + "</a>";
            var div = $( \'<div>\', {style: {position: \'absolute\', left: \'-99999px\'}, html: sel + pagelink} );
            $( \'body\' ).append( div );
            sel.selectAllChildren( div[0] );
            window.setTimeout(function() {
                div.remove();
                },0);
});