当元素的内容被复制到剪贴板时,JavaScript 中会发生哪个事件?
htmljavascriptprogramming scripts更新于 2026/1/14 6:36:17
当用户复制元素的内容时,会触发 oncopy 事件。
示例
您可以尝试运行以下代码来了解如何在 JavaScript 中实现 oncopy 事件。
<!DOCTYPE html>
<html>
<body>
<input type = "text" oncopy = "copyFunction()" value = "copy the text">
<script>
function copyFunction() {
document.write("文本已复制!");
}
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

