Read more at:
A largely ineffective technique used by some websites. This page was prompted when I was researching information on the suppression of keywords from Google Analytics reports.
I am not suggesting that you do this on your website when I first came across the technique I wondered how it was done. I now know and I am curious to analyse the code.
I say that this is ineffective as anyone copying text from a website so that they can copy it to their own website will see that there is a URL embedded when they paste the text into their own document. If the text is pasted into a blog or a Social Media post then it is likley to have a rel="nofollow" attribute added to the URL hyperlink. This is because the administrators of blogs and sites that allow users to add content are aware that this is a way of websites attempting to add links to themselves (Back Links) into other websites with the purpose of getting incoming links. If this was allowed then the page ranking of the site the link (copied text) is inserted into.
How this is done
After looking at a few solutions found on the Internet, the code referenced on Stackoverflow is shown below:
The JavaScript for the addition of the URL
<script>
function addLink() {
//Get the selected text and append the extra info
var selection = window.getSelection(),
pagelink = '<br /><br /> Read more at: ' + document.location.href,
copytext = selection + pagelink,
newdiv = document.createElement('div');
//hide the newly created container
newdiv.style.position = 'absolute';
newdiv.style.left = '-99999px';
//insert the container, fill it with the extended text, and define the new selection
document.body.appendChild(newdiv);
newdiv.innerHTML = copytext;
selection.selectAllChildren(newdiv);
window.setTimeout(function () {
document.body.removeChild(newdiv);
}, 100);
}
document.addEventListener('copy', addLink);
</script>
This code only works when run from the Internet - a local copy will not have a URL
How to copy just the URL of a page to the clipboard
Judging by the Impressions that I get for this page it would seem that those that are searching are just trying to copy the URL of a web page to the clipboard. This is really easy and not the topic that I discuss on this page.
The best way to copy a URL is to do so from the URL box in your browser.