Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

Pesquisar no site de suporte

Evite golpes de suporte. Nunca pedimos que você ligue ou envie uma mensagem de texto para um número de telefone, ou compartilhe informações pessoais. Denuncie atividades suspeitas usando a opção “Denunciar abuso”.

Saiba mais

Esta discussão foi arquivada. Faça uma nova pergunta se precisa de ajuda.

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?

  • 7 respostas
  • 10 têm este problema
  • 2 visualizações
  • Última resposta de msameer

more options

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 !

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 !

Solução escolhida

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

Ler esta resposta 👍 1

Todas as respostas (7)

more options

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.

more options

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!

more options

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.

Alterado por David McRitchie em

more options

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.

more options

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

more options

Solução escolhida

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

Alterado por sctl em

more options

Thanks folks for your help. Reply from #sctl was helpful in finding a tool for cleaning up the "garbage" ms word introduces.