JS清理Word格式
2014-02-13 10:16
375 查看
<input type="button" onclick="cleanWord();" 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;
}
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;
}
相关文章推荐
- 用JS清除word保存为html格式后产生的垃圾代码
- 如何使用html自定义或采用jquery.wordexport.js第三方插件以word格式导出
- js判断输入的字符串是否是日期格式
- 再议 js 数字格式之正则表达式
- JS实现带格式的复制到剪贴板
- 客户端生成Word(JS)
- 在WindowsLiveWriter中保持Word格式粘贴
- 在js里获取json格式的时间
- js操作cookie,将字符串数据解析为json格式
- 【Code】Js-mind插件中会使用到的一个递归拼装数据格式的函数
- 浅谈 js 数字格式类型
- js格式化日期格式
- 关于 JSNO XML 这两种数据格式的解析记录
- word 批量选取相同格式的内容
- js将long日期格式转换为标准日期格式
- js时间戳与日期格式之间的相互转换
- Word提供的【样式和格式】设计!
- 部署tomcat暴露html格式日志,并定期清理日志