Horje

How to Execute a JavaScript when copying an image

Img Example.
index.html
Example: HTML
<p>Try to copy the image below (Right click on the image and select "Copy Image").</p>

<img src="https://horje.com/avatar.png" oncopy="myFunction()" alt="The Scream" width="220" height="277">

<p><strong>Note:</strong> This example may not work as expected in some browsers.</p>

<script>
function myFunction() {
  alert("You copied image!");
}
</script>

Output should be:

How to Execute a JavaScript when copying an image




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin