當元素內容複製到剪貼簿時,JavaScript 中會發生哪些事件?


當用戶複製元素內容時,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>

更新於:2020 年 5 月 23 日

101 次瀏覽

開啟你的職業生涯

完成課程獲得認證

立即開始
廣告