Learn html - html tutorial - Oncopy attribute in html - html examples - html programs
The oncopy attribute specifies the user duplicates the content of an element .
The oncopy attribute is a section of the Event Attributes .
There are three actions to copy the content of an element:
Press CTRL + C
Select "Copy" from the Edit menu in a browser
Right click to show the context menu and select "Copy" command.
Syntax for oncopy attribute in HTML:
<input oncopy ="script" >
Applies To:
Element
Attribute
All HTML Elements
oncopy
oncopy Attribute Values:
Value
HTML 4.0.1
HTML 5
Description
script
yes
yes
The script can run on oncopy.
Sample Coding for oncopy Attribute in HTML:
Tryit<!DOCTYPE html>
<html >
<body >
<input type ="text" value ="HTML" oncopy ="Wikitechy()" >
<p id ="wikitechy" > </p >
<script >
function Wikitechy ( ) {
document .getElementById("wikitechy" ).innerHTML = "Copied the text!"
}
</script >
</body >
</html >
Code Explanation for oncopy Attribute in HTML:
<input> tag defines an input field where the user can enter input data.
value attribute defines the value of the HTML element .
Oncopy attribute defines when the user copied the element .
id attribute defines an individual id for an HTML element. The value of Id is wikitechy .
function Wikitechy() is a JavaScript function (block of code), which is created to perform this specific task.
<document.getElementById("wikitechy").innerHTML="Copied the text !">
document.getElementById gives the element which has the ID attribute with the defined value(Here Id value is wikitechy ).innerHTML returns the content of an element.
Output for oncopy Attribute in HTML:
Here we see the output, the text HTML is displayed when I click the HTML.
When I Press CTRL + C The text HTML has been copied.
After coping the text, the content Copied the text! has been displayed.
Browser Support for oncopy Attribute in HTML:
Tips and Notes
The oncopy attribute is mainly applied on <input> elements with type="text"
The oncopy attribute cannot work as normal in some web browsers through trying to copy an image.
Related Searches to oncopy attribute in html
onpaste event jquery
onpaste event in javascript
javascript onpaste get pasted data
onpaste jquery
onpaste get pasted text
onpaste not working
onpaste event get text
react onpaste
html tutorials html editor html code html form html tutorial html color html color codes html table html img html5 html code for website html and css html programs html website free html editor html5 tutorial wysiwyg html editor html tutorial pdf html converter php tutorial html example html tutorial css tutorial html css html tags html basics code html html online html mailto html lang html tags list