Multiple lines of text to clipboard

2019-06-02 22:58发布

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)

3条回答
趁早两清
2楼-- · 2019-06-02 23:09

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

查看更多
贼婆χ
3楼-- · 2019-06-02 23:19

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.

查看更多
狗以群分
4楼-- · 2019-06-02 23:20

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

查看更多
登录 后发表回答