简体   繁体   English

如何使用JavaScript复制到剪贴板并使其成为HTML?

[英]How to Copy to Clipboard in JavaScript and make it HTML?

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? 我在这里找到了一些不错的解决方案,有关如何在JavaScript中将文本复制到剪贴板:在JavaScript中如何复制到剪贴板?

But is there any way to give it a type? 但是有没有办法给它一个类型呢? Want I want is to paste to clipboard something like: 我想要的是将类似以下内容粘贴到剪贴板:

this is < b >bold< /b > 这是<b>粗体</ b>

and when pasting it into OpenOffice or Word, get 并将其粘贴到OpenOffice或Word中时,

this is bold 这是大胆的

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 . 请参阅此问题的答案,该问题显示了在将字符串复制到剪贴板之前如何进行字符串操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM