简体   繁体   中英

copy HTML text using the clipboard javascript API

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

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

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.

Any help appreciated.

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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