JavaScript for manipulating copied text

I copied the source code from The Huffington Post article and found that the website somehow shouted a link to my clipboard:

The text I selected. Blah. Blah. Blah.

More details: http://www.huffingtonpost.com/ ...

How did they do it?

+4
source share
2 answers

The code that does this is at http://www.huffingtonpost.com/include/lib/copy_paste.js?v=1.02

It seems that with the mouse events that they check to check if any text is selected, and if it is then, they insert an invisible div containing the quote inside the selection.

+5
source

http://snipplr.com/view/6450/javascript-copy-text-to-clipborad/ contains the function of copying text to the clipboard.

This probably happened in the copy event: it receives the selected text and adds "More ...", then it calls a function similar to the one given above.

+2
source

All Articles