views:

424

answers:

2

I've seen some questions on catching the paste event. This looks helpful. But I want to prevent paste on a designmode iframe from happening when the pasted content is not plaintext, but comes from MS Word or other WYSIWYG editor.

What is Your experience on that?

I suppose I should catch the event (bind to iframe or to its body?) and look for some specific tags in the clipboard. What content does Ms Word add every time?

[edit] After doing more research I see there is no easy way to work with clipboard in non Internet Explorer browser except some Flash tricks. I don't want them. How can I detect paste in Firefox and others then?

A: 

You are probably better off catching the paste event and then cleaning the pasted content to only contain valid HTML. It will be some fun regular expressions but I am sure you can find some one who has already written some of them online.

PetersenDidIt
I need a way to cross-browser catch it first ;) And I counted on some observations of tags that always appear in msword generated html. Do You know any? Anyway thanx
naugtur
+2  A: 

Read This Too!

http://stackoverflow.com/questions/2176861/javascript-get-clipboard-data-on-paste-event-cross-browser

And also this:

http://www.quirksmode.org/dom/events/cutcopypaste.html

Then i think, you need to go with flash object + javascript! ;-)

this is the one i have used in my project!

UPDATE:

keep in mind, that << Just because another browser allows you to do copy/past doesn't mean it's "good", "safe" or "right." >>

Firefox it's not buggy, it's just need to grant your page permission to access the clipboard!

http://www.infogears.com/cgi-bin/infogears/mozilla_firefox_copy_paste.html

http://www.mozilla.org/projects/security/components/per-file.html

https://developer.mozilla.org/en/Using_the_Clipboard

aSeptik
that quirksmode link is cool. Where do I search for details? They put green lights on prevent default for all browsers I'm interested in, but to prevent default I need to find out how to catch this buggy FF event, right? :)
naugtur
see the updates! ;-)
aSeptik
Quirksmode said it's buggy ;) I can't force users to do setup before using my app, so this doesn't fix the problem. I think I'll give it up now and come back to it later. Thanks for great links.
naugtur