• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Seemingly tricky JavaScript problem

jgbishop

Senior member
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?
 
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.
 
Back
Top