showing results for - "js get paste text"
Amy
05 Jan 2018
1function handlePaste (e) {
2    var clipboardData, pastedData;
3
4    // Stop data actually being pasted into div
5    e.stopPropagation();
6    e.preventDefault();
7
8    // Get pasted data via clipboard API
9    clipboardData = e.clipboardData || window.clipboardData;
10    pastedData = clipboardData.getData('Text');
11    
12    // Do whatever with pasteddata
13    alert(pastedData);
14}
15
16document.getElementById('editableDiv').addEventListener('paste', handlePaste);