Javascript DOM oncopy Event via HTML Tag oncopy function

Introduction

In JavaScript:

object.oncopy = function(){
       myScript};

This example uses the HTML DOM to assign an "oncopy" event to an input element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<input type="text" id="myInput" value="Try to copy this text">
<p id="demo"></p>
<script>
document.getElementById("myInput").oncopy = function() {myFunction()};

function myFunction() {//from  w w w  . j  av  a  2 s.  c o  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