多行文本到剪贴板 [英] Multiple lines of text to clipboard

查看:115
本文介绍了多行文本到剪贴板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用javascript将多行的文字发送到剪贴板?

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

IE,我想发送:

abc
def
ghi 

而不是

abcdefghi

(虽然现在我需要学习如何在Javascript中完成它,我不介意听到它是如何用其他语言完成的,像python)

推荐答案

将其作为一个字符串发送,其中包含回车符和换行符,正如Russ建议的那样。

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

你回答Russ说它不起作用:它的症状是什么?

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

如果您要从剪贴板复制到HTML,请注意当您将HTML插入DOM时,HTML DOM不一定保留空格(尤其包括回车符和换行符)。

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.

这篇关于多行文本到剪贴板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆