YouTip LogoYouTip

Event Onpaste

# onpaste Event [![Image 4: Event Object Reference](#) Event Object](#) ## Example Execute JavaScript when text is pasted in an element: [Try it Β»](#) More examples can be found at the bottom of this page. * * * ## Definition and Usage The onpaste event occurs when the user pastes some content in an element. **Note:** Although the onpaste event is supported by all HTML elements, it is not actually supported by all elements, for example, the

element, unless the contenteditable attribute is set to "true" (see more examples below). **Tip:** The onpaste event is most often used with elements. **Tip:** There are three ways to paste content into an element: * Press CTRL + V * Select "Paste" from the browser's Edit menu * Right-click the mouse button and select the "Paste" command in the context menu. * * * ## Browser Support | Event | | | | | | | --- | --- | --- | --- | --- | --- | | onpaste | Yes | Yes | Yes | Yes | Yes | * * * ## Syntax In HTML: (#) In JavaScript: _object_.onpaste=function(){_myScript_};(#) In JavaScript, using the addEventListener() method: _object_.addEventListener("paste", _myScript_);(#) **Note:** Internet Explorer 8 and earlier IE versions do not support the [addEventListener()](#) method. * * * Technical Details | Bubbles: | Yes | | --- | | Cancelable: | Yes | | Event type: | ClipboardEvent | | Supported HTML tags: | All HTML elements | * * * ![Image 5: Examples](#) ## More Examples ## Example Execute JavaScript when text is pasted in a

element (note the contenteditable attribute is set to "true"):

Try pasting content in this paragraph.

[Try it Β»](#) * * * ## Related Pages HTML DOM Reference: (#) HTML DOM Reference: (#) [![Image 6: Event Object Reference](#) Event Object](#)
← Hashes HdelStrings Setrange β†’