Not directly. IE has had the paste event since 5.5, Firefox since 3.0. Getting the clipboard data directly is generally impossible.
What you can do is quite involved and a bit of a hack that will work in Firefox 2+, IE 5.5+ and recent WebKit browsers such as Safari 4 or Chrome (untested on older versions). Recent versions of both TinyMCE and CKEditor use this technique:
- Detect a ctrl-v / shift-ins event using a keypress event handler
- In that handler, save the current user selection, add a textarea element off-screen (say at left -1000px) to the document, turn
designMode
off and call focus()
on the textarea, thus moving the caret and effectively redirecting the paste
- Set a very brief timer (say 1 millisecond) in the event handler to call another function that stores the textarea value, removes the textarea from the document, turns
designMode
back on, restores the user selection and pastes the text in.
Note that this will only work for keyboard paste events and not pastes from the context or edit menus. By the time the paste event fires, it's too late to redirect the caret into the textarea (in some browsers, at least).
Note also that in Firefox 2 you'll need to place the textarea in the parent document rather than the WYSIWYG editor iframe's document.