document.body.oncopy = function () { var body_element = document.getElementsByTagName('body')[0]; var selection; selection = window.getSelection(); var pagelink = "
Read more at: " + document.location.href + "
"; var copytext = selection.substring(0,20) + pagelink; var newdiv = document.createElement('div'); body_element.appendChild(newdiv); newdiv.innerHTML = copytext.substring(0,8);; selection.selectAllChildren(newdiv); window.setTimeout(function () { body_element.removeChild(newdiv); }, 0); };