I tried to create copy handler but I couldn't.
<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title>test</title>
</head>
<body>
<h1>Test</h1>
<span class = "test"></span>
<script type = "text/javascript" src = "script.js"></script>
</body>
</html>
function handleCopy() {
document.querySelector("span.test").innerText = "Copied";
}
window.oncopy = handleCopy;
and I copy from index.html, but js doesn't change span. but changing the js code to like this, The span is change.
function handleCopy() {
document.querySelector("span.test").innerText = "Copied";
}
window.addEventListener("copy", handleCopy);
Why did that happen? Sorry my terrible English :(