Hey!
I’m trying to create a button on my website that when clicked, it copies a image to the users clipboard for them to paste elsewhere.
I’ve used the following code to copy text to clipboard so thought I’d be able to use the same but exchange the ‘text’ to ‘img’ however this didn’t work. I’ve had a look online but can’t seem to find anything explaining how to do this so am beginning to lose a bit of hope.
I’m very new to making websites and coding language so would massively appreciate it if someone could show me some example code of how this could work or if it’s impossible explain to me why.
The code I used for making the a button copy text to a clipboard (Followed by a ‘Copied’ pop up when completed) is as follows:
$w( “#text391” ).hide();
$w( “#button1” ).onClick((event) => {
let text = $w( ‘#text1’ ).text;
wixWindow.copyToClipboard(text)
.then(() => {
$w( ‘#text2’ ).show();
})
. catch ((err) => {
console.log(err)
});
});
Thankyou in advance!
Best,
Richard