PHP前端开发

当一个元素的内容被复制到剪贴板时,在JavaScript中会发生哪个事件?

百变鹏仔 4周前 (09-22) #HTML
文章标签 剪贴板

当用户复制元素的内容时,oncopy 事件就会触发。

示例

您可以尝试运行以下代码以了解如何在 JavaScript 中实现 oncopy 事件。

<!DOCTYPE html><html>   <body>      <input type = "text" oncopy = "copyFunction()" value = "copy the text">      <script>         function copyFunction() {            document.write("Text copied!");         }      </script>   </body></html>