Something as simple as this?
let myString = "foo";
copyToClipboard(myString);
Something as simple as this?
let myString = "foo";
copyToClipboard(myString);
There are two ways to interact with the clipboard:
document.execCommand("copy")
< Which you said you don't want to use.navigator.clipboard.write
The support for the more modern second option is lacking though: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write
There is currently no other supported way :)