Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> </head> <body> <p>该实例演示了如何使用 HTML DOM 向 input 元素中添加 "onpaste" 事件。</p> <input type="text" id="myInput" value="尝试在此处粘贴文本" size="40"> <script> document.getElementById("myInput").onpaste = function() {myFunction()}; function myFunction() { alert("你粘贴了文本!"); } </script> </body> </html>