The oncopy event is triggered when the user copies the content on the element. That is, when the user copies the content existing in the element, the oncopy event will be triggered. oncopy can be used with img, input, p and other elements.
oncopy accepts a single value script that is run when oncopy is called. (For more oncopy content, please refer to: HTML Tutorial Manual)
There are three ways to copy elements and content:
Press Ctrl C
in your Select "Copy" from the browser's Edit menu
Right-click the mouse button and select the "Copy" command from the context menu.
The syntax of oncopy is as follows:
<element oncopy = "script">
Let’s look at a specific example
The code is as follows
<!DOCTYPE How to use oncopy event> <How to use oncopy event> <head> <title>oncopy attribute</title> <style> body { text-align:center; } h1 { color:green; } </style> </head> <body> <h2>oncopy事件</h2> <p oncopy="Geeks()">php中文网: php编程的学习网站</p> <p id="sudo"></p> <script> function Geeks() { document.getElementById("sudo").innerHTML = "Copied Text" } </script> </body> </How to use oncopy event>
The effect is as follows
This article ends here. For more exciting content about the front-end, you can pay attention to the relevant column tutorials on the PHP Chinese website! ! !
The above is the detailed content of How to use oncopy event. For more information, please follow other related articles on the PHP Chinese website!