Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is politico.com inserting a hyperlink into copied text?

Tags:

javascript

If you visit this article on politico.com, highlight some of the article text, then paste that text elsewhere, it will contain a link that says "Read more at: ...". How is this done?

Update: This is the JS used, but hard to follow: http://tcr.tynt.com/javascripts/Tracer.js

like image 232
Ron Avatar asked May 15 '09 20:05

Ron


1 Answers

I assume that it's just like any copy to clipboard script, but you insert the "Read more at :.." text in the front, and you listen for the oncopy event.

So instead of just doing: window.clipboardData.setData("Text", textToCopy);

you'd do

window.clipboardData.setData("Text", "Read more at: mysite.com , " + textToCopy);

More here:

http://www.daniweb.com/forums/thread53662.html

like image 162
quoo Avatar answered Oct 19 '22 01:10

quoo