Created
December 5, 2019 14:24
-
-
Save pulketo/c19585a5f23d504d744f03dcb7962515 to your computer and use it in GitHub Desktop.
javascript on paste event
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
| var myElement = document.getElementById('pasteElement'); | |
| myElement.onpaste = function(e) { | |
| var pastedText = undefined; | |
| if (window.clipboardData && window.clipboardData.getData) { // IE | |
| pastedText = window.clipboardData.getData('Text'); | |
| } else if (e.clipboardData && e.clipboardData.getData) { | |
| pastedText = e.clipboardData.getData('text/plain'); | |
| } | |
| alert(pastedText); // Process and handle text... | |
| return false; // Prevent the default handler from running. | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment