Multiple lines of text to clipboard

为君一笑 提交于 2019-12-08 05:11:25

问题


Is there a way to send multiple lines of text to the clipboard using javascript?

IE, I want to send:

abc
def
ghi 

and not

abcdefghi

(and although right now i need to learn how to do it in Javascript, I would not mind hearing how it is done in other languages, like python)


回答1:


Send it as one string with carriage return and line feed characters in it, as Russ suggested.

You replied to Russ that, "it does not work": what's the symptom of it not working?

If you're copying from the clipboard into HTML, note that whitespace (especially including carriage return and line feed characters) is not necessarily preserved by the HTML DOM when you insert it into the DOM.




回答2:


did you try 'abc\r\ndef\r\nghi\r\n'




回答3:


I haven't tested it, but check out some of the jQuery plugins. http://plugins.jquery.com/taxonomy/term/657



来源:https://stackoverflow.com/questions/923581/multiple-lines-of-text-to-clipboard

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