Forum Moderators: open
<body oncopy="alert('Copyright My Name 2013');"> <meta name="pinterest" content="nopin">
<style>
#copymsg {
display: none;
}
</style>
<body oncopy="mentionCopyright();">
<div id="copymsg">© Example.com 2013</div>
<script type="text/javascript">
function mentionCopyright()
{
document.getElementById('copymsg').style.display='block';
// Prepare page link and copyright message, to append to copied content
var pageurl = document.location.href.match(/https?:\/\/(.+)/)[1];
var pagelink = "<br>Read more at: <a href='"+document.location.href+"'>"+pageurl+"</a><br>Copyright © Example.com 2013";
if (window.getSelection)
{
// 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');
newdiv.style.position='absolute';
newdiv.style.left='-99999px';
var body_element = document.getElementsByTagName('body')[0];
body_element.appendChild(newdiv);
var newpar=document.createElement("p");
newpar.innerHTML = pagelink;
// Check whether more than just a quote is copied
if (selectionSize < 900)
newdiv.appendChild(selectionContents);
else {
// Replace copied part with contents of description meta tag
var desc;
var descs = document.getElementsByName('description')[0];
if (typeof descs !== 'undefined')
desc = descs.getAttribute('content');
else
desc = "Please copy no more than a quote from this article ('fair use' as to international copyright laws).";
var newcontent=document.createElement("p");
newcontent.innerHTML = desc;
newdiv.appendChild(newcontent);
}
newdiv.appendChild(newpar);
selection.selectAllChildren(newdiv);
window.setTimeout(function() {
body_element.removeChild(newdiv);
},0);
}
}
}
</script>