Javascript DOM HTML Image handle copy event

Introduction

Execute a JavaScript when copying an image:

This example may not work as expected in some browsers.

View in separate window

<!DOCTYPE html>
<html>
<body>

<p>Try to copy the image below.</p>

<img src="image1.png" oncopy="myFunction()" width="100" height="132">

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

</body>
</html>



PreviousNext

Related