為了改善您的使用體驗,本網站正在進行維護,部分功能暫時無法使用。若本站的文件無法解決您的問題,想要向社群發問的話,請到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 發問,我們的社群成員將很快會回覆您的疑問。

搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

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 回覆
  • 10 有這個問題
  • 75 次檢視
  • 最近回覆由 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 !

被選擇的解決方法

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

從原來的回覆中察看解決方案 👍 1

所有回覆 (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.

由 David McRitchie 於 修改

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

選擇的解決方法

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

由 sctl 於 修改

more options

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