Javascript clipboard manipulation after section has been copied from website

£可爱£侵袭症+ 提交于 2019-12-07 08:43:11

问题


When I copy a section of test from this website

my clipboard gets extra text appended to the end of it saying "Read more: " then the url of the page I was reading (plus a unique looking string on the end)

How have they done this?


回答1:


I've made some reverse engineering and it looks like this script is responsible for clipboard manipulation:

http://tcr.tynt.com/ti.js (use http://jsbeautifier.org/ to see uncompressed code)

See the introduction movie on this website:

http://www.tynt.com/

Technically I don't know how is it done, looks like they don't use Flash but make use of getSelection() function and copy, contextmenu events.




回答2:


When your select text on their page (before the Copy happens) a zero-height div containing the extra text ("Read more: .....") is created off the page (position: absolute; top: -1000px) and that text is then added to the selection.

So when you copy your selected text, you are also copying the text that is hidden off the page.



来源:https://stackoverflow.com/questions/8820445/javascript-clipboard-manipulation-after-section-has-been-copied-from-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!