Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 903
lovespring Avatar asked Nov 06 '22 05:11

lovespring


1 Answers

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

like image 51
DVK Avatar answered Nov 15 '22 03:11

DVK