Answers for "paste javascript"

0

js get paste text

function handlePaste (e) {
    var clipboardData, pastedData;

    // Stop data actually being pasted into div
    e.stopPropagation();
    e.preventDefault();

    // Get pasted data via clipboard API
    clipboardData = e.clipboardData || window.clipboardData;
    pastedData = clipboardData.getData('Text');
    
    // Do whatever with pasteddata
    alert(pastedData);
}

document.getElementById('editableDiv').addEventListener('paste', handlePaste);
Posted by: Guest on July-09-2020
2

js paste event

const target = document.querySelector('div.target');

target.addEventListener('paste', (event) => {
    let paste = (event.clipboardData || window.clipboardData).getData('text');
    paste = paste.toUpperCase();
 
    const selection = window.getSelection();
    if (!selection.rangeCount) return false;
    selection.deleteFromDocument();
    selection.getRangeAt(0).insertNode(document.createTextNode(paste));

    event.preventDefault();
});
Posted by: Guest on June-18-2020
0

js paste

navigator.clipboard.readText().then(text => outputElem.innerText = text);
Posted by: Guest on June-25-2021

Code answers related to "paste javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language