HTML event attribute oncopy








The oncopy attribute event is triggered when copying the content of an element.

What's new in HTML5

None.

Syntax

<element oncopy="script or Javascript function name">

Supported Tags

ALL HTML elements

Browser compatibility

oncopy Yes Yes Yes Yes Yes




Example

<!DOCTYPE html>
<html>
<body>
<!--   w  w w .j  av a  2  s. co m-->
<p oncopy="myFunction()">Copy me</p>

<script>
function myFunction() {
    console.log("You copied text!");
}
</script>

</body>
</html>

Click to view the demo