Last active
September 13, 2016 20:32
-
-
Save typeofweb/622ec101076540c980703c1d41e61982 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 onCopy(e) { | |
try { | |
e.clipboardData.setData('Text', 'tekst do skopiowania'); | |
e.preventDefault(); | |
} catch (err) { | |
console.error(err); | |
} | |
} | |
function onClick() { | |
try { | |
window.document.oncopy = onCopy; | |
window.document.execCommand('copy'); | |
} catch (err) { | |
onError(); | |
} finally { | |
window.document.oncopy = undefined; | |
} | |
} | |
button.addEventListener('click', onClick, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment