Created
September 25, 2015 06:34
-
-
Save dannyid/cfc0fa982e5afd8b29cc to your computer and use it in GitHub Desktop.
For use in a Chrome extension. Don't forget to enable the "clipboardWrite" permission.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyToClipboard(text) { | |
const input = document.createElement('input'); | |
input.style.position = 'fixed'; | |
input.style.opacity = 0; | |
input.value = text; | |
document.body.appendChild(input); | |
input.select(); | |
document.execCommand('Copy'); | |
document.body.removeChild(input); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment