It may be duplicate question but i didnt find the solution for this.
I am trying to copy text on button click. Its working on chrome, mozilla(working on on windows a
using the copy event seems to work for me.
copy
window.addEventListener('copy', (event) => { event.preventDefault(); event.clipboardData.setData('text/plain', `foo: ${Date.now()}`); });
click here, press Cmd-C, paste outside the browser
tested in Chrome 83, Safari 13.1, Firefox 77