How to: Add a Copyright Notice to Copied Text

How to: Add a Copyright Notice to Copied Text

Some of you may noticed a 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 secretes behind this magic.

This is not a big magic thing. I just simply running a JavaScript function for this magic. This function grab 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.

function addLink() {
	var body_element = document.getElementsByTagName('body')[0];
	var selection;
	selection = window.getSelection();
	var pagelink = "<br /><br /> Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br />Copyright © LineshJose.com"; // change this if you want
	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;

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

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.
* **
*
* Required. **will not be published.
  1. Thanks for sharing the script. I’ve been looking for it for quite some time.