How do I copy an image to the clipboard (Clipboard)?

Asked

Viewed 1,452 times

6

I’m using this command to capture the screen.

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

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

How do I do that?

1 answer

6

I had 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 in the original OS (and the others that it references) has very useful explanations in this regard: https://stackoverflow.com/questions/10221298/copy-image-to-clipboard-not-working-in-firefox-chrome

Now, considering that the 'image' parameter that your callback receives contains the URL of the captured image, depending on its intention (that is, if you do not want to simply leave the image to be pasted by the user in any external application) Maybe you can save the URL to a hidden html element or something. Or you can even use a Flash bridge as some users suggested in the above thread. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.