javascript – How can I copy an image to the clipboard (Clipboard)?


I'm using this command to capture the web.

chrome.tabs.captureVisibleTab(null, {}, function (image) {
    // image = base64;string

And now I would like to copy the captured image to the clipboard.

How do I do that?


I needed to do something like this in the recent past and I couldn't come up with a solution either. Apparently browsers (with the exception of IE) do not support copying anything other than text for security reasons. This thread on the original OS (and the others it references) has very useful explanations about it:

Now, considering that the 'image' parameter that your callback receives contains the URL of the captured image, depending on your intention (that is, if you don't just want to leave the image to be pasted by the user in any external application) you might be able to save the url in a hidden html element or something. Or you can even use a Flash bridge as some users suggested in the thread indicated above. 🙂

Scroll to Top