首页 > 语言 > JavaScript > 正文

js清理Word格式示例代码

2024-05-06 16:00:50
字体:
来源:转载
供稿:网友
这篇文章主要介绍了使用JS清理Word格式的方法,需要的朋友可以参考下

复制代码 代码如下:


<input type="button" value="Word清理" />

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;
}

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选