Last active
June 3, 2021 10:27
-
-
Save tsvetomir/0d2a251987c039e03d2251605c525e09 to your computer and use it in GitHub Desktop.
Copy markup
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
<button onclick="copyMarkup()">Copy source!</button> | |
<script> | |
function copyMarkup() { | |
const box = document.createElement('textarea'); | |
box.style.position = 'absolute'; | |
box.style.left = '-10000px'; | |
box.setAttribute('cols', '1000'); | |
document.body.appendChild(box); | |
box.value = document.documentElement.innerHTML; | |
box.select(); | |
document.execCommand('copy'); | |
e.target.innerHTML = "Success!"; | |
setTimeout(() => document.body.removeChild(box), 100); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment