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:
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:
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 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:
Yes
Yes
Yes
Yes
Yes
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.