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 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始學習
廣告
© . All rights reserved.