Javascript Reference
Categories: onbeforepaste

javascript onbeforepaste Description

@March 15, 2008, 1:22 a.m.
onbeforepasteFirefox/Netscape/NN n/a IE 5(Win) Chrome/Safari/DOM n/a  

Bubbles: Yes; Cancelable: Yes  

Fires just before a user-initiated Paste command (via the Edit menu, a keyboard shortcut, or a context menu) completes the task of pasting the content from the system clipboard to the current selection. If you are trying to paste custom information from the clipboardData object (saved there in an onbeforecopy, oncopy, onbeforecut, or oncut event handler), you need to have the onbeforepaste and onpaste event handler functions working together. Set event.returnValue to false in the onbeforepaste event handler so that the Paste item in the Edit (and context) menu is activated, even for a noneditable paste target. When the user selects the Paste menu choice, your onpaste event handler retrieves information from the clipboardData object and perhaps modifies the selected element's HTML content:

function handleBeforePaste( ) {
    event.returnValue = false;
}
function handlePaste( ) {
    if (event.srcElement.className == "OK2Paste") {
        event.srcElement.innerText = clipboardData.getData("Text");
    }
}
 

In the above paste operation, the system clipboard never plays a role because your scripts handle the entire data transferall without having to go into edit mode.

 
Typical Targets

All rendered elements and the document object.

atorvastatin 20mg cost <a href="https://lipiws.top/">lipitor 80mg drug</a> order atorvastatin 40mg sale
Wrlnzd - 10 months

Powered by Linode.