views:

75

answers:

2

I copied come text from a The Huffington Post article and found that the web site had somehow snuck a citation onto my clipboard:

The text I had selected. Blah. Blah. Blah.

Read more at: http://www.huffingtonpost.com/...

How did they do that?

+2  A: 

http://snipplr.com/view/6450/javascript-copy-text-to-clipborad/ contains a function on how to copy text to the clipboard.

It's probably done on the copy event: gets the currently selected text and adds the "Read more... " then calls a function similar to the one linked above.

John Boker
+1  A: 

The code that does this is in http://www.huffingtonpost.com/include/lib/copy%5Fpaste.js?v=1.02

It looks like on mouse-up events they check to see if any text is selected, and if it is then they insert an invisible div containing the citation inside of the selection.

Laurence Gonsalves