如何使用JavaScript复制到剪贴板并使其成为HTML? [英] How to Copy to Clipboard in JavaScript and make it HTML?

查看:122
本文介绍了如何使用JavaScript复制到剪贴板并使其成为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屋!

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