javascript onbeforepaste Description
onbeforepaste | Firefox/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. |
Powered by Linode.