Last active
December 16, 2016 01:47
-
-
Save jaredly/76ea78ae3633722d41f734dea49c3003 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
| <html> | |
| <head> | |
| <title>onpaste</title> | |
| </head> | |
| <body> | |
| <div id="root"></div> | |
| <script> | |
| const log = txt => { | |
| const div = document.createElement('div') | |
| document.body.appendChild(div) | |
| div.innerText = txt | |
| } | |
| const makeTxt = () => { | |
| const txt = document.createElement('textarea') | |
| document.body.appendChild(txt) | |
| return txt | |
| } | |
| document.body.addEventListener('paste', function(e) { | |
| [].map.call(e.clipboardData.items, item => { | |
| log(item.kind + ' : ' + item.type) | |
| const txt = makeTxt() | |
| item.getAsString(ss => txt.value = ss) | |
| }) | |
| }); | |
| </script> | |
| <div>paste here | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment