使用剪贴板javascript API复制HTML文本 [英] copy HTML text using the clipboard javascript API

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

问题描述

我希望能够复制图像和HTML文本并将其粘贴到我的Web应用程序中.

I want to be able to copy images and HTML text and past it into my web application.

我正在使用剪贴板API来执行此操作,并且我的代码可以很好地用于图像,为此,我使用了:读取剪贴板API

I am using the clipboard API to do so and my code works fine for images, for which I use: clipboard API read

但是对于文本,我使用的是:剪贴板API readText 而且我只能粘贴原始文本,不能粘贴HTML格式的文本.

But for text, I am using this: clipboard API readText And I am only able to paste the raw text, not the HTML formatted text.

任何帮助表示赞赏.

推荐答案

Safari Chrome Canary ,只需调用 navigator.clipboard.write text/html 一样,就像您当前通过 image/png 使用图像一样.

This should already be possible in Safari and Chrome Canary, by simply calling navigator.clipboard.write with text/html, just like you currently do so with images via image/png.

(这是在Chrome 86中实现的,因此 10月6日将在稳定版Chrome中提供)

(This was implemented in Chrome 86, and so will available in Stable Chrome by October 6)

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

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