Js clean up the Word format sample code

  • 2020-03-30 01:42:06
  • OfStack

 
<input type="button" onclick="cleanWord();" value="Word Clean up the " /> 

cleanWord = function(){ 
var editBody = FCKeditorAPI.GetInstance("text").EditorDocument.body; 
var html = FCKeditorAPI.GetInstance("text").EditorDocument.body.innerText; 
for(var intLoop=0;intLoop<editBody.all.length;intLoop++){ 
el=editBody.all[intLoop]; 
  el.removeAttribute("className","",0); 
  el.removeAttribute("style","",0); 
  el.removeAttribute("font"," ",0); 
} 
html=html.replace(/<o:p> </o:p>/g,""); 
html=html.replace(/o:/g,""); 
html=html.replace(/<font>/g,""); 
html=html.replace(/<FONT>/g,""); 
html=html.replace(/<span>/g,""); 
html=html.replace(/<SPAN>/g,""); 
html=html.replace(/<SPANlang=EN-US>/g,""); 
html=html.replace(/<P>/g,""); 
html=html.replace(/</P>/g,""); 
html=html.replace(/</SPAN>/g,""); 
FCKeditorAPI.GetInstance("text").EditorDocument.body.innerText=html; 
} 

Related articles: