javascript 是否有粘贴后发生的事件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4532473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there an event that occurs after paste?
提问by lovespring
Possible Duplicate:
Detect pasted text with ctrl+v or right click -> paste
I'm coding a js editor now. I want to do something (detect pasted text, etc.) just after the paste.
我现在正在编写一个 js 编辑器。我想在粘贴之后做一些事情(检测粘贴的文本等)。
回答by DVK
Here's an example of handling paste event:
这是处理粘贴事件的示例:
http://www.quirksmode.org/dom/events/tests/cutcopypaste.html
http://www.quirksmode.org/dom/events/tests/cutcopypaste.html
It's supported on many browsers but not 100% - see this table for compatibility: http://www.quirksmode.org/dom/events/cutcopypaste.html
许多浏览器都支持它,但不是 100% - 请参阅此表以了解兼容性:http: //www.quirksmode.org/dom/events/cutcopypaste.html
You can also work around not having a paste event on some browsers by:
您还可以通过以下方式解决在某些浏览器上没有粘贴事件的问题:
Remembering full contents of the form field at some time
Setting a timeout event
On timeout, take the contents of the field again, compare to the previous contents, and detect changes. Lather, rinse, repeat
有时会记住表单域的全部内容
设置超时事件
超时时,再次获取该字段的内容,与之前的内容进行比较,并检测更改。起泡,冲洗,重复

