HTML oncopy Event Attribute

Description

The event attribute oncopy allows you to set the script to fire when the user copies the contents of an element.

Syntax

<element oncopy="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE html> 
  <html> 
    <head>
      <title>oncopy event</title> 
    </head> 
    <body> 
    <input type="text" oncopy="copyAlarm()" value="Copy this text"> 
    <p id="test"> </p> 
<script> 
function copyAlarm() {
  document.getElementById("test").innerHTML="Text has been copied to clipboard!"; 
} 
</script> 
  </body> 
</html>

Supported Tags

All HTML tags.

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
??????
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
??????