SHARE
Facebook X Pinterest WhatsApp

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

Written By
thumbnail
Scott Clark
Scott Clark
Jan 13, 2011


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: https://www.htmlgoodies.com/beyond/javascript/article.php/3920531

Recommended for you...

The Revolutionary ES6 Rest and Spread Operators
Rob Gravelle
Aug 23, 2022
Ahead of Time (AOT) Compilation in Angular
Tariq Siddiqui
Aug 16, 2022
Converting a JavaScript Object to a String
Rob Gravelle
Aug 14, 2022
Understanding Primitive Type Coercion in JavaScript
Rob Gravelle
Jul 28, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.