Select-copy from web page adds page hyperlink to clipboard

If you select a paragraph, for example, http://www.wired.com/gadgetlab/2010/01/ipad-flash/ and insert it into the word, you will notice that a link to this page has been added at the end of the paragraph.

Here is an example:

Some of Apple's promotional materials for the iPad include devices. The Safari browser can download Adobe Flash content. However, the tablet’s demonstration units, including those presented by Steve Jobs, could not, and the consumer has already filed a federal trade complaint with the Commission alleging false advertising.

Read more http://www.wired.com/gadgetlab/2010/01/ipad-flash/#ixzz0f2nM0huW

How do they do it?

They also add # ixzz0f2nM0huW at the end of the link, and when you follow the page, the selected text will be highlighted!

Is there a javascript library for this?

+4
source share
1 answer

They use Tynt Insight . This is a commercial JavaScript library that comes with a free version that includes the "link attribution" feature described in your question.

You can see how this is indicated in their HTML in the <head> :

 <!-- Tynt Tracer> --> <script type="text/javascript"> tyntVariables = {"ap":"Read More"}; </script> <script type="text/javascript" src="http://tcr.tynt.com/javascripts/Tracer.js?user=ac4i_23GOr3QjHab7jrHcU&s=112"></script> 

As Tim Down noted in the comment above, Anirvan gave a very good briefing on the internal components of the Tynt script in a separate entry.

+5
source

Source: https://habr.com/ru/post/1300740/


All Articles