Use JavaScript to Add a Read More Link When Text is Copied From Your Site

By Scott Clark


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

You may have been to a website and went to copy some text from the page and noticed that when you pasted the text it also copied a "read more" note which included the URL of the page you copied from. In this tutorial we will show you how you can do the same thing using a tidbit of JavaScript.

The folks at Tynt Insight have made this task easy for you. All you need to do is sign up for the service (which only involves providing your site's domain name, your email address and a password), and the Tynt service creates the code for you.

Using the Tynt Service

Once you have logged in, or created a new account, you will be provided with several choices:

You are able to choose whether or not to display an attribution link (i.e. a link to the page they are copying from), as well as a Creative Commons License, and you are able to choose where the link/license appears: above the copied text or below it.

Once you have made your choices, you are provided with the specific JavaScript code you will need for the effect to work, as shown here:

You simply take the code they provide, and paste it into the HEAD of your web page. Once you've done that, your work is done. The loading time of the script is negligable, and once the page is loaded, the script is working, ready for someone to copy from it. Here is what it looks like when you have copied and pasted something when using this script:

copied text, copied text, copied text, copied text, copied text, copied text, 
copied text, copied text, copied text, copied text, copied text, copied text

read more: http://www.htmlgoodies.com/beyond/javascript/article.php/3920531

  • Web Development Newsletter Signup

    Invalid email
    You have successfuly registered to our newsletter.
Thanks for your registration, follow us on our social networks to keep up-to-date