YouTip LogoYouTip

Event Oncopy

# oncopy Event [![Image 4: Event Object Reference](#) Event Object](#) ## Example Execute JavaScript when text is copied on an element: [Try it Β»](#) More examples are included at the bottom of this page. * * * ## Definition and Usage The oncopy event occurs when the user copies the content of an element. **Tip:** The oncopy event also occurs when the user copies an element, for example, copying an element. **Tip:** The oncopy event is most often used with elements with type="text". **Tip:** There are three ways to copy an element and its content: * Press CTRL + C * Select "Copy" in the Edit menu of your browser * Right-click the mouse button and select the "Copy" command in the context menu. * * * ## Browser Support | Event | | | | | | | --- | --- | --- | --- | --- | --- | | oncopy | Yes | Yes | Yes | Yes | Yes | **Note:** The oncopy event may not work in Chrome, Firefox, and Opera when trying to copy an image (see more examples). * * * ## Syntax In HTML: (#) In JavaScript: _object_.oncopy=function(){_myScript_};(#) In JavaScript, using the addEventListener() method: _object_.addEventListener("copy", _myScript_);(#) **Note:** Internet Explorer 8 and earlier 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 the text content of a

element is copied:

Try copying text

[Try it Β»](#) ## Example Execute JavaScript when an image is copied: [Try it Β»](#) * * * ## Related Pages HTML DOM Reference: (#) HTML DOM Reference: (#) [![Image 6: Event Object Reference](#) Event Object](#)
← Event OnafterprintEvent Onsubmit β†’