Question

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?

Was it helpful?

Solution

The code that does this is in http://www.huffingtonpost.com/include/lib/copy_paste.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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top