HTML oncopy 속성은 사용자가 HTML 문서에서 HTML 요소의 내용을 복사할 때 트리거됩니다.
구문
다음은 구문입니다 -
<tagname oncopy=”script”></tagname>
예시
HTML oncopy 이벤트 Attribute −
의 예를 살펴보겠습니다.<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
color: #000;
height: 100vh;
background-color: #FBAB7E;
background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);
text-align: center;
padding: 20px;
}
p {
font-size: 1.1rem;
}
</style>
</head>
<body>
<h1>HTML oncopy Event Attribute Demo</h1>
<p oncopy="get()">I'm a paragraph HTML element with some dummy text.</p>
<p style="color:#db133a;">Now try to copy above paragraph text.</p>
<div class="show"></div>
<script>
function get() {
document.body.style.background = "lightblue";
}
</script>
</body>
</html> 출력

이제 단락 요소의 내용을 복사하여 oncopy 이벤트 속성이 작동하는 방식을 관찰해 보십시오.
