skimberk1
skimberk1

Reputation: 2094

Processing paste to contentEditable

I'm creating my own custom WYSIWYG editor, and I'd like all HTML to be removed from pasted content.

I do this by focusing a textarea on the paste event, then after a 10 millisecond timeout, I insert the contents of the textarea into the contentEditable.

Example: http://jsfiddle.net/JPM6p/

This is working great in Chrome, but doesn't work in Firefox or Internet Explorer. Does anyone know how to fix this?

Thanks

EDIT: Apparently it works in Firefox 6.0.2 on Mac OS X, so perhaps it works only in earlier verions of Firefox?

Upvotes: 4

Views: 7465

Answers (1)

Tim Down
Tim Down

Reputation: 324507

You need to focus the textarea before the paste event fires in some browsers, which means you can only realistically use this technique for pastes triggered by keyboard shortcuts such as Ctrl-V. Here's a similar question with more information:

https://stackoverflow.com/a/2177059/96100

Upvotes: 2

Related Questions