Home > Web Front-end > HTML Tutorial > How to use oncopy event

How to use oncopy event

不言
Release: 2019-02-13 09:24:53
Original
2752 people have browsed it

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.

How to use oncopy event

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">
Copy after login

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>
Copy after login

The effect is as follows

How to use oncopy event

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template