HTML onpaste Event Attribute

Description

The event attribute onpaste allows you to set the script to fire when the user inserts content into an element.

Syntax

<element onpaste="script">

Values

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

Example

<!DOCTYPE html> 
  <html> 
    <head>
      <title>onpaste event</title> 
    </head> 
    <body> 
    <textarea onpaste="pasteAlarm()">Paste text here.</textarea> 
    <p id="test"> </p> 
    <script> 
function pasteAlarm() {
  document.getElementById("test").innerHTML = "The onpaste attribute has been triggered."; 
} 
</script> 
  </body> 
</html>

Supported Tags

All HTML tags (in most cases, the tag should have the value of the attribute contenteditable="true").

Browser Support

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