Seemingly tricky JavaScript problem

jgbishop

Senior member
May 29, 2003
521
0
0
I'm developing an extension for Firefox, and I've run into a JavaScript problem. I'd like to be able to receive notification when a user pastes text into an edit box. Does anyone know of a way to do this?

The "onkeypress" or "onkeyup" commands work fine if the user uses Ctrl+V to paste text. But I cannot seem to get notification when they use their mouse (right click in the edit box and select Paste).

Does anyone know of a way to reliably do this?
 

UCJefe

Senior member
Jan 27, 2000
302
0
0
As far as I know, only IE supports the onPaste() event handler so I think this is impossible. A quick search turned up this forum post which says you can't do it and a few other links which all imply that IE is the only browser that supports this functionality. I would look around a little bit more though before you conclude it can't be done.

Depending on your exact needs, maybe something like detecting a text change and changing it back would work? Or if you get a text change notification without a keypress event you could assume a paste. Sure they're hacks but I'm not sure of your other options.