开发者

Is there an event that occurs after paste? [duplicate]

开发者 https://www.devze.com 2023-02-01 09:14 出处:网络
This question already has answers here: Closed 12 years ago开发者_Python百科. Possible Duplicate: Detect pasted text with ctrl+v or right click -> paste
This question already has answers here: Closed 12 years ago开发者_Python百科.

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.


Here's an example of handling paste event:

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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消