Adding copyright message to copied material
On the most popular part of one of my websites, I have since many years had an onCopy event on the body tag, which launches an alertbox with a copyright message, like this:
<body oncopy="alert('Copyright My Name 2013');">
This used to work only in Internet Explorer, but I noticed that it now also works in Firefox, Chrome, Opera and Safari. Good.
Since people still copy my material (articles with photos) without permission, I'm looking for ways to improve this.
I'm thinking about automatically adding a copyright message to any piece of copied text. Any other ideas?
I'm already using Pinterest's meta tag, like this:
<meta name="pinterest" content="nopin">
Are there any other social media that have a similar meta tag or other code to prevent copying?
I'm sure folks can recommend some technical approaches to use, but keep the above in mind when formulating your overall strategy.
I actually don't want to completely block copying, as I want to allow users to copy something to quote, and put a link next to that quote. I just want to tell them that what they are copying is copyrighted, and that I do not permit republishing without permission.
I hope that I'm blocking at least some of the scrapers in my .htaccess.
I would recommend taking a look at Tynt -- it might do what you want. If it's not what you want, it could serve as an example of the same sort of script you'll want to make for your purposes.
Thanks for mentioning Tynt :-)
That indeed gave me some interesting ideas I could code myself. They seem to believe that the majority of copying goes through copy and paste, so for the time being I'll focus on just that.
Perhaps I could detect it when users copy an entire article to the clipboard, and in that case replace the copied text with the contents of the description meta tag, with a link to the page, and a copyright message.
If they're copying just a part of an article, I could add a link underneath the text.
And if they're copying just a few words, they're probably copying keywords that they'll put into a search box somewhere. No need to do anything to that.
I wrote this code (adapting from various sources on the web) to make what I described in my previous post (more or less). It should work fine in Internet Explorer 9 and higher, and latest versions of Firefox, Chrome, Opera, Safari for Windows.
The article is expected to be within ARTICLE tags.
The description meta tag should have the word "description" in lower case, or else the alternative message will show.
<div id="copymsg">© Example.com 2013</div>
// Prepare page link and copyright message, to append to copied content
var pageurl = document.location.href.match(/https?:\/\/(.+)/);
var pagelink = "<br>Read more at: <a href='"+document.location.href+"'>"+pageurl+"</a><br>Copyright © Example.com 2013";
// Get selected part of the article
var selection = window.getSelection();
var selectionContents = selection.getRangeAt(0).cloneContents();
var selectionSize = selection.toString().length;
// Check if contents of more than one HTML element is copied
var container = selection.getRangeAt(0).commonAncestorContainer;
if (container.nodeName == "ARTICLE")
// Helper DIV
var newdiv = document.createElement('div');
var body_element = document.getElementsByTagName('body');
newpar.innerHTML = pagelink;
// Check whether more than just a quote is copied
if (selectionSize < 900)
// Replace copied part with contents of description meta tag
var descs = document.getElementsByName('description');
if (typeof descs !== 'undefined')
desc = descs.getAttribute('content');
desc = "Please copy no more than a quote from this article ('fair use' as to international copyright laws).";
newcontent.innerHTML = desc;