views:

191

answers:

2

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

+7  A: 

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

quoo
This isn't what they do - that would fail in all but the most insecure browser set-ups. What that script actually does is append the extra text in a hidden div to your selection as you do it. Then when you copy it includes the extra info. Very clever!
Keith
+1  A: 

On politico.com, the code that does what you say there is in tracer.js.

DDaviesBrackett