如何使用JavaScript复制到剪贴板并使其成为HTML? [英] How to Copy to Clipboard in JavaScript and make it HTML?
问题描述
我在这里找到了一些不错的解决方案,它们涉及如何将JavaScript中的文本复制到剪贴板中: 如何使用JavaScript复制到剪贴板?
I found some nice solutions here on how to copy text in JavaScript to the clipboard in: How do I copy to the clipboard in JavaScript?
但是有什么办法可以给它一个类型?我想要的是将类似以下内容粘贴到剪贴板中:
But is there any way to give it a type? Want I want is to paste to clipboard something like:
这是< b> bold</b>
this is < b >bold< /b >
并将其粘贴到OpenOffice或Word中时,获取
and when pasting it into OpenOffice or Word, get
这是粗体
推荐答案
您可以在将用户选择的字符串发送到剪贴板之前对其进行操作.请参阅此问题的答案该示例显示了在复制之前如何进行字符串操作到剪贴板.
You could just manipulate the string the user selects before sending it to the clipboard. Refer the answer for this question which shows how a string manipulation could be done before copying it to the clipboard.
这篇关于如何使用JavaScript复制到剪贴板并使其成为HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!