Js cleanup Word Format sample code
This article mainly introduces how to use JS to clear the Word format. For more information, see
The Code is as follows:
<Input type = "button" onclick = "cleanWord ();" value = "Word cleanup"/>
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;
}