去除word格式的页面
2007-02-15 09:29
411 查看
文章录入界面自己写的文字可以录进,从word拷过来的文字录不进去,疑为word自带格式问题,好像要用正则表达式去除,我才初学.net自己没有办法写出来,望大家帮忙
// 清除WORD冗余格式并粘贴
function cleanAndPaste( html ) {
// Remove all SPAN tags
html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
// Remove Class attributes
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove Style attributes
html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
// Remove Lang attributes
html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove XML elements and declarations
html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
// Remove Tags with XML namespace declarations: <o:p></o:p>
html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
// Replace the
html = html.replace(/ /, " " );
// Transform <P> to <DIV>
var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
html = html.replace( re, "<div$2</div>" ) ;
alert( html ) ;
}
// 清除WORD冗余格式并粘贴
function cleanAndPaste( html ) {
// Remove all SPAN tags
html = html.replace(/<\/?SPAN[^>]*>/gi, "" );
// Remove Class attributes
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove Style attributes
html = html.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, "<$1$3") ;
// Remove Lang attributes
html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3") ;
// Remove XML elements and declarations
html = html.replace(/<\\?\?xml[^>]*>/gi, "") ;
// Remove Tags with XML namespace declarations: <o:p></o:p>
html = html.replace(/<\/?\w+:[^>]*>/gi, "") ;
// Replace the
html = html.replace(/ /, " " );
// Transform <P> to <DIV>
var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)","gi") ; // Different because of a IE 5.0 error
html = html.replace( re, "<div$2</div>" ) ;
alert( html ) ;
}
相关文章推荐
- jsp页面中显示word/excel格式的文档的方法
- word页面设置问题。通过域设置首页不计算页面的自定义页码格式
- 在Java中导出word、excel格式文件时JSP页面头的设置
- Word:如何去除标题格式中前面那个点
- kindeditor粘贴word去除格式
- Word:如何去除标题格式中前面那个点
- jsp页面中显示word/excel格式的文档的方法
- 基于summernote的富文本编辑器,粘贴时去除word格式
- kindeditor粘贴word文档内容时去除格式的方法?如何设置为默认无文本格式呢?
- 将word文档按原格式放在jsp页面里
- 批量设置word文档的页面格式 word vba代码注释
- ASP.NET导出Excel或Word文件格式
- 基于XML的Word文档格式智能识别
- 用C#去除字符串中HTML的格式
- php导出word格式数据的代码实例
- ckeditor编辑器Word文档粘贴自动去格式的解决方法
- python操作word(改课文格式)【最终版】
- Word中去除表格边框
- 4-6-word2003-Word其他格式与插入符号
- 将GridView或其他页面元素导出到Word