When I copy a text from MS Word and paste it into my HTML page in Firefox, it brings over too many style definitions. Can that be avoided?
Basically I have an HTML with DIV tag and having contentEditable set to true. Whenever I copy content from MS Word and paste it in this html, it brings over tons of styles and messes up the whole content. Same set of actions work fine on same HTML in IE !
Soluzione scelta
There is an online tool at
http://demo.typps.com/Editor/mswordcleanup.aspx and http://www.textism.com/wordcleaner/ (for 20kb docs or less)
that will strip Word's proprietary tags from an HTML document.
You might find the following article to be informative:
http://gabesumner.com/copy-from-ms-word-paste-into-a-rich-text-wysiwyg-editor
You can always use the SeaMonkey Composer editor instead of Word. See:
http://www.seamonkey-project.org/
SeaMonkey is a Mozilla project built from Firefox.
edited to add textism
Leggere questa risposta nel contesto 👍 1Tutte le risposte (7)
One solution -- don't do that.
Microsoft wrote both IE and MS Word, IE will be looking at the same code generated.
So what do you mean that you get too many styles, is that an error message, or you just don't like the generated code, or that the generated code does not work.
I don't get any errors and generated code works. But the generated code overcomplicates the basic styles. E.g. I used bold feature on a word called "Hello" and and I get 50 styles added in the div field after copy-paste. Whereas in case of IE I get a clean tag around the same word "Hello". So this operation is more clean and intelligent in case of IE but in case of Firefox it just puts so much data that my field widths are on the brink of overflow!
Would you supply the application, content, url descriptions as well as you can for each, and exactly what you are doing.
- 1) source where "Hello" is being brought from
- 2) target where you are pasting into with Firefox
- 3) and with IE
- 4) where you see the source directly in what you paste or by viewing source
Is this a WYSIWYG editor where what you normally see is what it is going to look like when finished.
A simple change or difference in fonts font-size could make a big difference in what is happening.
Modificato da David McRitchie il
Sure. I can. How do I attach it here? There is one sample HTML file and then i can send a sample Word document with a bold "Hello" text just to illustrate the issue.
Extra code is one of the pitfalls of using WYSIWYG cutting and pasting, and using styling in general.
So while it may be interesting to try to reduce the amount of code, there probably won't be any direct approach without extra steps to get you what you want with bare bones code that appears as you want it to or at least acceptable.
I guess you might have to take a screen image, clip the relevant portion, since you can only attach an image file here not a text file.
Posting a screen shot
Soluzione scelta
There is an online tool at
http://demo.typps.com/Editor/mswordcleanup.aspx and http://www.textism.com/wordcleaner/ (for 20kb docs or less)
that will strip Word's proprietary tags from an HTML document.
You might find the following article to be informative:
http://gabesumner.com/copy-from-ms-word-paste-into-a-rich-text-wysiwyg-editor
You can always use the SeaMonkey Composer editor instead of Word. See:
http://www.seamonkey-project.org/
SeaMonkey is a Mozilla project built from Firefox.
edited to add textism
Modificato da sctl il
Thanks folks for your help. Reply from #sctl was helpful in finding a tool for cleaning up the "garbage" ms word introduces.