开发者

JavaScript to Manipulate Copied Text

开发者 https://www.devze.com 2022-12-09 08:40 出处:网络
I copied come text from a The Huffington Post article and fo开发者_如何学JAVAund that the web site had somehow snuck a citation onto my clipboard:

I copied come text from a The Huffington Post article and fo开发者_如何学JAVAund 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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消