Created
January 29, 2018 09:57
-
-
Save lankaapura/7cbd320a63da8350a2c3ad573b079be0 to your computer and use it in GitHub Desktop.
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 CopyToClipBoardHandler(value) { | |
const copyListener = event => { | |
document.removeEventListener('copy', copyListener, true); | |
event.preventDefault(); | |
const clipboardData = event.clipboardData; | |
clipboardData.clearData(); | |
clipboardData.setData('text/plain', value); | |
}; | |
document.addEventListener('copy', copyListener, true); | |
document.execCommand('copy'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment