How to: Add a Copyright Notice to Copied Text

How to: Add a Copyright Notice to Copied Text

Some of you may notice copyright info and a reference link to the source, at the bottom of a copied text content from this site. Yea it’s copy-protected!. I get a lot of mails asking about this magic. So I’d like to reveal the secrets behind this magic.

This is not a big magic thing. I just simply running a JavaScript function for this magic. This function grabs the copied content, insert a copyright notice, and then add to the clipboard. Thanks to c.bavota for his great script. According to the developer, this function will work for all major browsers except Internet Explorer.

Here is the Magic.Just copy this script and paste it into the “<head> </head>” tags.

<script>
function addLink() {
var body_element = document.getElementsByTagName('body')[0];
var selection;
selection = window.getSelection();
// change this if you want
var pagelink = "

Read more at: <a href=""+document.location.href+"">"+document.location.href+"</a>
Copyright © Linesh.com";
var copytext = selection + pagelink;
var newdiv = document.createElement('div');
newdiv.style.position='absolute';
newdiv.style.left='-99999px';
body_element.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function() {
body_element.removeChild(newdiv);
},0);
}
document.oncopy = addLink;
</script>

Source: http://bavotasan.com/2010/add-a-copyright-notice-to-copied-text/