Latest web development tutorials

oncopy event

Event Object Reference Event objects

Examples

JavaScript is executed when the <input> element to copy text:

<Input type = "text" oncopy = "myFunction ()" value = "try to copy text">

try it"

The bottom of the article contains more examples.


Definition and Usage

oncopy event is triggered when users copy content element.

Tip: oncopy event will be triggered when the user copy elements, such as a copy of <img> element.

Tip: oncopy event is often used type = "text" of the <input> elements.

Tip: There are three ways you can copy elements and content:

  • Press CTRL + C
  • (Edit) menu, select "Copy (Copy)" in your browser's Edit
  • Mail mouse button and select "Copy (copy)" command in the context menu.

Browser Support

event
oncopy Yes Yes Yes Yes Yes

Note: When you try to copy a picture (see more instances), oncopy events may not be applied in Chrome, Firefox and Opera browsers.


grammar

In HTML:

<Elementoncopy = "myScript"> try

In JavaScript:

object .oncopy = function () {myScript }; try

JavaScript, use the addEventListener () method:

object .addEventListener ( "copy", myScript ); try

Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.


technical details
Whether to support the bubble: Yes
It can be canceled: Yes
Event Type: ClipboardEvent
Supported HTML tags: All HTML elements


Examples

More examples

Examples

JavaScript is executed in the copy <p> elements in the text:

<P oncopy = "myFunction ()"> try to copy text </ p>

try it"

Examples

Executed copy pictures JavaScript:

<Img src = "w3schools.gif" oncopy = "myFunction ()">

try it"


Related Pages

HTML DOM Reference: onpaste event

HTML DOM Reference: oncut event


Event Object Reference Event objects