Typicalc/frontend/src/copy-to-clipboard.js

10 lines
320 B
JavaScript
Raw Normal View History

2021-01-27 23:31:27 +00:00
window.copyToClipboard = (str) => {
const textarea = document.createElement("textarea");
textarea.value = str;
textarea.style.position = "absolute";
textarea.style.opacity = "0";
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
};