多行文本到剪贴板
有没有办法使用 JavaScript 将多行文本发送到剪贴板?
IE,我想发送:
abc
def
ghi
而不是
abcdefghi
(虽然现在我需要学习如何在 Javascript 中做到这一点,但我不介意听听它是如何在其他语言中完成的,比如 python)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你尝试过“abc\r\ndef\r\nghi\r\n”吗
did you try 'abc\r\ndef\r\nghi\r\n'
正如 Russ 所建议的,将其作为一个字符串发送,其中包含回车符和换行符。
你回复拉斯说,“它不起作用”:它不起作用的症状是什么?
如果您从剪贴板复制到 HTML 中,请注意,当您将空格(尤其是回车符和换行符)插入到 DOM 中时,HTML DOM 不一定会保留空格。
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.
我还没有测试过,但查看了一些 jQuery 插件。
http://plugins.jquery.com/taxonomy/term/657
I haven't tested it, but check out some of the jQuery plugins.
http://plugins.jquery.com/taxonomy/term/657