Javascript DOM oncopy Event via HTML Tag oncopy attribute

Introduction

This example demonstrates how to assign an "oncopy" event to an input element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" oncopy="myFunction()" value="Try to copy this text">

<p id="demo"></p>
<script>
function myFunction() {//  w  w  w .jav  a 2s .co  m
  document.getElementById("demo").innerHTML = "You copied text!";
}
</script>

</body>
</html>
Bubbles: Yes
Cancelable: Yes
Event type: ClipboardEvent
Supported HTML tags: All HTML elements



PreviousNext

Related