Add Website Link in text copied from your Website

If you want to add your website link in the text copied from your website then you can use the script given on this page. This technique does not protect your website data but helps you in spreading your website link through the copied text.



The java script to add your website link in the copied text is given below:

<script type='text/javascript'>
function addLink() {
    //Get the selected text and append the extra info
    var selection = window.getSelection();
    pagelink = &quot;. Read more at: &quot; + document.location.href;
    copytext = selection + pagelink;
//Create a new div to hold the prepared text
    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>

I personally used it several blogger blogs. You can add the above code just before </head> . It works perfectly like that in blogger code.

Spreading your link is a good thing to make your website popular. Adding this code can help you in attaining that target. Several people just copy paste text from your website without even noticing the link copied with it. You can utilize such copy-paste and spread your link by using this simple script.

Hope it will work for you !
Share this Article :
Email

No comments:

Post a Comment